|
-
Apr 1st, 2004, 10:30 PM
#1
Thread Starter
Junior Member
If Statement problem...
Im really sad....because of the simple problem, i cannot move to the another doc....
im very new in this vb.net...so, im really hoping dat anybody out there will help me...
i make an entry form using txt box and date..
i need the user to key in the name of document,date and payment...
for the beginning, i list 10 entry...
my problem is, if the user only fill until the third textbox, then i print it, the value of the default date will be print also...
im using this statement:
if txtD1.text <> " " or txtP1.text <> 0 then
'print the name of document
'print the date selected
'print the payment
end if
but, i dont know y the compiler will ignore the txtD1.text that equal to blank, and then print the 3 item,,,the problem is with the default date..it will appear until the list of 10 eventhough i'm only insert 3 entry....
plzzzz....someone help me....
the date line is close but i'm stuck if the simple if statement....
i dont know to make it no print the default date....for information, i'm using datetime picker.....
-
Apr 1st, 2004, 11:29 PM
#2
Junior Member
VB Code:
if txtD1.text <> " " or txtP1.text <> 0 then
'print the name of document
'print the date selected
'print the payment
end if
but, i dont know y the compiler will ignore the txtD1.text that equal to blank,
I don't exactly understand what your asking for. But, if your testing for txtD1.text to be an empty string (i.e. "") then you need to type it like that, "", not " " (no space).
Right now if txtD1 doesn't contain anything, then your line:
txtD1.text <> " "
will evaluate to true because your asking if it's not equal to one space...
change it to:
txtD1.text <> ""
and try again.
Mike
-
Apr 2nd, 2004, 12:21 AM
#3
Thread Starter
Junior Member
-
Apr 2nd, 2004, 12:45 AM
#4
Junior Member
np. You might also want to use trim:
txtD1.text.trim <> ""
to make sure that you account for someone putting just a space in there and not realizing it.
-
Apr 3rd, 2004, 07:48 AM
#5
PowerPoster
HI,
What's with the "or txtP1.text <> 0 then"???
What are you testing for - a zero value or the character 0?
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Apr 3rd, 2004, 08:02 AM
#6
Hyperactive Member
if txtD1.text <> " " or txtP1.text <> 0 then
In the above case you test a zero value
If you want to test a 0 character:
if txtD1.text <> " " or txtP1.text <> "0" then
Good job
Live long and prosper (Mr. Spock)
-
Apr 3rd, 2004, 02:24 PM
#7
PowerPoster
HI,
"txtP1.text <> 0 then"
What I am trying to draw your attention to is that you are NOT testing for zero value. You are testing for the number 0. If an alphabetical letter or a null is in txtP1.Text, you will get a runtime error.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Apr 4th, 2004, 03:50 AM
#8
Hyperactive Member
Hi, Taxes.....I agree perfectly with you.
I was not sufficiently care to view the entire question and I only was concentrated on to show the difference,in general, between with and without quotes, thinking it was the our friends Aziera's doubt.
Live long and prosper (Mr. Spock)
-
Apr 4th, 2004, 11:49 PM
#9
Thread Starter
Junior Member
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
|