Problem with form

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2009
Posts: 56
Reputation: songweaver is an unknown quantity at this point 
Solved Threads: 0
songweaver songweaver is offline Offline
Junior Poster in Training

Problem with form

 
0
  #1
Nov 4th, 2009
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.

  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
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 5
Reputation: pasanbuddhika is an unknown quantity at this point 
Solved Threads: 2
pasanbuddhika pasanbuddhika is offline Offline
Newbie Poster
 
0
  #2
Nov 4th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 56
Reputation: songweaver is an unknown quantity at this point 
Solved Threads: 0
songweaver songweaver is offline Offline
Junior Poster in Training

Reply

 
0
  #3
Nov 4th, 2009
It is still not working, here is what I have:

  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
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 5
Reputation: pasanbuddhika is an unknown quantity at this point 
Solved Threads: 2
pasanbuddhika pasanbuddhika is offline Offline
Newbie Poster
 
0
  #4
Nov 4th, 2009
line 7 correct as
  1. If getAge > 65 And isChecked == True Then

and also line 9
  1. ElseIf getAge < 65 And isChecked == True Then

I think it's ok
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 56
Reputation: songweaver is an unknown quantity at this point 
Solved Threads: 0
songweaver songweaver is offline Offline
Junior Poster in Training
 
1
  #5
Nov 4th, 2009
Its giving me an error with ==, it only accepts =
Originally Posted by pasanbuddhika View Post
line 7 correct as
  1. If getAge > 65 And isChecked == True Then

and also line 9
  1. ElseIf getAge < 65 And isChecked == True Then

I think it's ok
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 56
Reputation: songweaver is an unknown quantity at this point 
Solved Threads: 0
songweaver songweaver is offline Offline
Junior Poster in Training

Nevermind

 
0
  #6
Nov 4th, 2009
It works!
Last edited by songweaver; Nov 4th, 2009 at 11:56 pm.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 5
Reputation: pasanbuddhika is an unknown quantity at this point 
Solved Threads: 2
pasanbuddhika pasanbuddhika is offline Offline
Newbie Poster
 
0
  #7
Nov 5th, 2009
change line 9 as
  1. Dim isChecked As Boolean = chkMemeber.CheckState
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC