|
-
Oct 7th, 2000, 07:26 AM
#1
Thread Starter
Addicted Member
Hi
Private Sub Command2_Click()
If Text1.Text = " " And Text2.Text = "" Then
MsgBox "textbox is empty "
End If
End Sub
The above if-else statement doesnt seems to work
Anyone can detect anything wrong with the code?
-
Oct 7th, 2000, 07:32 AM
#2
Well, there isn't anything wrong, other than:
Code:
If Text1.Text = " " And Text2.Text = "" Then
You have a space at Text1.Text = " "
Even if you were meant to use the space, it seems to work fine.
Sunny
-
Oct 7th, 2000, 07:33 AM
#3
Frenzied Member
The code is ok, but it will only fire the MessageBox when both Textboxes are empty, to make the code work if one of (or both) the textboxes are empty replace the AND with OR
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 7th, 2000, 07:43 AM
#4
Thread Starter
Addicted Member
Thanks for the reply
I tried a simpler if else statement that goes:
Code:
if text1.text=" " then
msgbox"textbox 1 is empty"
endif
even thought i fufill the condition above no mesage box is display
-
Oct 7th, 2000, 07:48 AM
#5
CoMMIE, " " doesn't mean it is empty, "" means it is empty. " " is the same as pressing the space bar once but thats not the same as nothing. " " still takes space to represent.
Your code should be
Code:
Private Sub Command2_Click()
If Text1.Text = "" And Text2.Text = "" Then 'space deleted
MsgBox "textbox is empty "
End If
End Sub
Sunny
-
Oct 7th, 2000, 07:52 AM
#6
Frenzied Member
I'm sorry but what are you trying to do?!
does the text1 exist at all and what's in it when pressing the button? when you delete all the contents in a textbox, the value of the textbox is "", not " " (< space)
Where do you fire the If Then Statement?
Code:
Private Sub Command1_Click()
'Will check if both boxes are empty
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "textbox 1 is empty"
End If
End Sub
Private Sub Command1_Click()
'Will check if one of the boxes are empty
If Text1.Text = "" And Text2.Text = "" Then
MsgBox "textbox 1 is empty"
End If
End Sub
I don't get it, what's not working for you?
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 7th, 2000, 07:57 AM
#7
Thread Starter
Addicted Member
Hi
I already found my solution thanks to Yonatan
Code:
Private Sub Command1_Click()
If Trim(Text1.Text) = vbNullString Then
MsgBox " "
Else
End If
Anyway thanks for spending time reading my post 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|