Results 1 to 9 of 9

Thread: If Statement problem...

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    17

    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.....

  2. #2
    Junior Member
    Join Date
    Apr 2004
    Posts
    19
    VB Code:
    1. if txtD1.text <> " " or txtP1.text <> 0 then
    2. 'print the name of document
    3. 'print the date selected
    4. 'print the payment
    5. 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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    17

    Smile thanks!

    oopss!

    wat a silly mistake!
    how can i skip checking on dis!

    anyway mike, u really HELP me..
    thanks a lot

    or either i'll stuck on da same page without noticing a very small mistake...


  4. #4
    Junior Member
    Join Date
    Apr 2004
    Posts
    19
    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.

  5. #5
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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.

  6. #6
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    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)

  7. #7
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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.

  8. #8
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    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)

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Posts
    17

    TQ




    well, i've learned a lot from here...

    Special thanks to all of u for sharing ur precious knowledge!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width