Results 1 to 9 of 9

Thread: Newbie

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    2

    Newbie

    Hi

    I am new to VB scritping and having problems with the IF then statements ... I know basic stuff :-)

    I want to validate a screen... I have a pull downlist and if a user choses an option I want to check that data is valid but I don't seem to be getting it right

    i.e. If a person chooses a value of SMS I want to ensure a mobile number has been entered on the page
    If a person selects Fax I want to ensure that a fax number has been entered on the page
    If Post then address and if Phone then a phione number has been entered

    and for all if they don't I want to show an error message .... this is causing me to go grey ... LOL...please advise on the best way to do this ... Thanks in advanced

    Cheers

  2. #2
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Newbie

    When you say VB scripting are you using VB.Net or one of the scripting variants like VBA?

  3. #3
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Newbie

    It's best to use a Select Case statement for something like this. Also, VB.NET is not scripting. It's a real programming language. It's not VB Script.

    vb Code:
    1. Select Case ComboBox1.SelectedIndex
    2. Case 0
    3.       'Do work for first selected item
    4. Case 1
    5.  
    6. Case 2
    7.  
    8. Case 3
    9.  
    10. End Case

    *Edit: Err... keystone_paul was quicker than me. I guess it does matter whether or not you've screwed up your vernacular or you really are using something like VB Script or VBA.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2010
    Posts
    2

    Re: Newbie

    I am using a VBA variant I tried

    If "aObjects("LP1030Commsmethod")" = "SMS" Then
    If "aObjects("LP10170Mobilenumber")" = "avar1" then
    fcTrigger = "ERR: Please provide a mobile number if SMS is the prefered method of communications"
    Else
    fcTrigger = "ERR: Else Triggered"
    End If
    End If

    And this doesn't seem to output the error message

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Newbie

    That wouldn't output anything if the first IF statement was false, therefore, that seems likely.
    My usual boring signature: Nothing

  6. #6
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Newbie

    But are you coding in VB.NET?
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Newbie

    I think we can assume that the answer is NO, but it doesn't really matter.

    I just noticed the quotation marks around: "aObjects("LP1030Commsmethod")"

    You may be expecting aObjects to be an object with a property, or some such, but by enclosing it in quotes, it becomes nothing more than a string litteral. aObjects isn't evaluated at all, it's just a string, which can't possibly equal the string "SMS", because it is the string "aObjects("LP1030Commsmethod")"

    Remove the quotation marks around that aObjects part in both of the If statements.
    My usual boring signature: Nothing

  8. #8
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Re: Newbie

    I think we can assume that the answer is NO, but it doesn't really matter.
    It matters because then this question doesn't belong in this section of the forum. But I was asking if he was because he said he was trying a variant of VBA. Which lead me to think he was trying to use VBA in VB.NET.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Newbie

    Moved To Office Development

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