Tuesday, November 16, 2010

How do i nestle an if and else statement in VB 6 to make it work?

For example, i have a text box and a submit button. How do i write the code in VB to say ';if there's something in the text box *and* the submit button is pressed, do this'; ? Please answer quickly!How do i nestle an if and else statement in VB 6 to make it work?
Throw this in your command/submit button :



If Len(Text1.text) %26gt; 0 Then

msgbox ';its populated';

Else

msgbox ';its not populated';

End If



Enjoy!How do i nestle an if and else statement in VB 6 to make it work?
u should go to a scientist lol.idk that kinda stuff.i jsut want the points!
Here you want two conditions to satisfy

1. Checking whether the textbox is empty or not

2. Submit button is clicked or not



To check the first condition the first answer you recieved is correct.

But I think you want both the conditions to satisfy



To do this just declare a variable

Assign the value of the variable as 0

Do it in the form load event



Dim A as Integer

A=0



Now in the submit click event

After the button is clicked change the value to 1

and after satisfying the conditions change back to 0



A = 1

If (A = 1) And Len(Text1.Text) %26gt; 0 Then

MsgBox ';write your code here';

Else

MsgBox ';write another code here';

End If

A=0

No comments:

Post a Comment