|From: sarah||E-mail: firstname.lastname@example.org||1|
Date: Sunday, October 21, 2001 at 20:25:21
Subject: Using selection in your visual basic program
I just started to learn vb6.0.
I have to write a simple program where, the user type in their age and depending on their age a message appears. Either saying "time to retire" if you are older than 65, or keep on working if your age is below 65.
I'm getting stuck on how you code the if and else statement.
This is what I have done so far.
private sub cmdmessage_click()
Dim age as integer
if age >65 then
txtage.text="time to retire"
txtage.text="keep on working"
My code above don't seem to work because any number i press it display keep
Could you please help me?
|From: Martin Allen||E-mail: <No e-mail>||2|
Date: Monday, October 22, 2001 at 20:36:46
Subject: RE: Using selection in your visual basic program
After you declare the variable using the 'Dim' statement, you need to give the variable a value. After the second line, insert the following code:
|age = txtNumber.Text|
Where txtNumber is the name of the textbox where the user enters the number. If you do not put this line in, the program will not know what the value of the 'age' variable is.
This forum is no longer taking new messages or replies since 01 November 2002. The above material is for reference purposes only.
The new Visual Basic 6.0 forum can be found here.