944,135 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 469
  • VB.NET RSS
Nov 4th, 2009
0

Problem with form

Expand Post »
Hey guys I am a newbie to VB and need help with this form,
The idea is that people enter there age and if they over 65 and are a member its one price, if they are under 65 its one price and if they are not a member it is one price. Age is entered into a textbox, memberahip is indicated by a checkbox and the price is then displayed in a textbox. Anyway I a confused about why it is not calculating. Here is what I have so far. Again I am very new to VB.

VB.NET Syntax (Toggle Plain Text)
  1. Public Class Form1
  2.  
  3. Private Sub btnPrice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrice.Click
  4. Dim getAge As Integer = txtAge.Text
  5. Dim isChecked As Integer = chkMemeber.Checked
  6. Dim showPrice As Integer = txtPrice.Text
  7. If getAge > 65 And isChecked = True Then
  8. txtPrice.Text = 5
  9. ElseIf getAge < 65 And isChecked = True Then
  10. txtPrice.Text = 10
  11. ElseIf isChecked = False Then
  12. txtPrice.Text = 20
  13. End If
  14.  
  15.  
  16. End Sub
  17. End Class
Similar Threads
Reputation Points: 17
Solved Threads: 0
Junior Poster in Training
songweaver is offline Offline
80 posts
since Mar 2009
Nov 4th, 2009
0
Re: Problem with form
Hai !
Error is the variable isCheskde should be Boolean.

I'm wonder why are you declare variable named showPrice. you never use it.
Last edited by pasanbuddhika; Nov 4th, 2009 at 10:51 pm.
Reputation Points: 3
Solved Threads: 2
Newbie Poster
pasanbuddhika is offline Offline
6 posts
since Apr 2009
Nov 4th, 2009
0

Reply

It is still not working, here is what I have:

VB.NET Syntax (Toggle Plain Text)
  1. Public Class Form1
  2.  
  3. Private Sub btnPrice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrice.Click
  4. Dim getAge As Integer = txtAge.Text
  5. Dim isChecked As Boolean = chkMemeber.Checked
  6.  
  7. If getAge > 65 And isChecked = True Then
  8. txtPrice.Text = 5
  9. ElseIf getAge < 65 And isChecked = True Then
  10. txtPrice.Text = 10
  11. ElseIf isChecked = False Then
  12. txtPrice.Text = 20
  13. End If
  14.  
  15.  
  16. End Sub
  17. End Class
Reputation Points: 17
Solved Threads: 0
Junior Poster in Training
songweaver is offline Offline
80 posts
since Mar 2009
Nov 4th, 2009
0
Re: Problem with form
line 7 correct as
VB.NET Syntax (Toggle Plain Text)
  1. If getAge > 65 And isChecked == True Then

and also line 9
VB.NET Syntax (Toggle Plain Text)
  1. ElseIf getAge < 65 And isChecked == True Then

I think it's ok
Reputation Points: 3
Solved Threads: 2
Newbie Poster
pasanbuddhika is offline Offline
6 posts
since Apr 2009
Nov 4th, 2009
1
Re: Problem with form
Its giving me an error with ==, it only accepts =
line 7 correct as
VB.NET Syntax (Toggle Plain Text)
  1. If getAge > 65 And isChecked == True Then

and also line 9
VB.NET Syntax (Toggle Plain Text)
  1. ElseIf getAge < 65 And isChecked == True Then

I think it's ok
Reputation Points: 17
Solved Threads: 0
Junior Poster in Training
songweaver is offline Offline
80 posts
since Mar 2009
Nov 4th, 2009
0

Nevermind

It works!
Last edited by songweaver; Nov 4th, 2009 at 11:56 pm.
Reputation Points: 17
Solved Threads: 0
Junior Poster in Training
songweaver is offline Offline
80 posts
since Mar 2009
Nov 5th, 2009
0
Re: Problem with form
change line 9 as
VB.NET Syntax (Toggle Plain Text)
  1. Dim isChecked As Boolean = chkMemeber.CheckState
Reputation Points: 3
Solved Threads: 2
Newbie Poster
pasanbuddhika is offline Offline
6 posts
since Apr 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: How to print data from vb form?
Next Thread in VB.NET Forum Timeline: Create an event handler for a third party library that I use





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC