Always happy to help.
Just for info (in case you didn't find this out yet) you can force VB to strip out any blank spaces at either end of a string of text by using Trim eg:
If Trim(TextBox1.Text) = "" Then
: ' whatever
This would then make it read " " as "", or "Hello " as "Hello" and so on.
Cheers
Ged
: Thanks for the help.Your code works perfect I found were I was my code was putting a blank space in the txtbox so the system was thinking something was there
:
: Thanks Again for your help
: Regards
: RGray
:
:
: : My guess would be that the problem will be with either or both of the two procedures you are calling - poerror or save. What code do you have in there?
: : I've tested the If/Then/Else logic and it definitely reacts correctly to any combination of text content in the two textboxes I used. Did you replace the names TextBox1 and TextBox2 in my code snippet with the correct names for your two boxes?
: : I hope I understood your original question correctly - this code snippet will call "poerror" if both boxes are empty at the same time. It will call "save" if either box has some text in it (even if the other one is empty).
: : One way to test the logic of the If/Then snippet is to replace the procedure calls with a simple messagebox. You can then write and delete code in the two textboxes, click the button and the message will tell you how the code has interpreted the textbox text status.
: :
: : Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
: : If TextBox1.Text = "" AndAlso TextBox2.Text = "" Then
: : MessageBox.Show(" poerror")
: : Else
: : MessageBox.Show(" save")
: : End If
: : End Sub
: :
: : If you need to call poerror if
either textbox is left empty, then use this alternative:
: :
: : Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
: : If TextBox1.Text = "" Or TextBox2.Text = "" Then
: : MessageBox.Show(" poerror")
: : Else
: : MessageBox.Show(" save")
: : End If
: : End Sub
: :
: : Without more info on your code there's not much else I can help you with at this stage.
: :
: : Ged
: : ====================================================================
: :
: :
: : : I must have something missing in my program. I can not make this work
: : : The button click does nothing with this code.
: : :
: : : Thanks for the help
: : : I will keep digging
: : :
: : : Regards
: : : RGray
: : :
: : : : There's a new operator now available in VB.Net - "andalso". In your scenario, you can use it like this:
: : : :
: : : : If TextBox1.Text = "" AndAlso TextBox2.Text = "" Then
: : : : poerror
: : : : Else
: : : : save
: : : : End If
: : : :
: : : :
: : : : ==================================
: : : :
: : : :
: : : : : How do you use if to check 2 txt box to confirm that there is something wriiten in them
: : : : : I am using
: : : : : If (txtpo.txt="")then
: : : : : call poerror()
: : : : : else
: : : : : call save()
: : : : : end If
: : : : : This works for 1 or the other but how can I make it work for both. I have tried setting up a second sub for the other txt box and changed the call save to second sub then the program does nothing
: : : : :
: : : : : Thanks for any help
: : : : : Rgray
: : : : :
: : : : :
: : : :
: : : :
: : :
: : :
: :
: :
:
: