dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Quick VBScript question

  1. #1
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    894

    Quick VBScript question

    Hi guys:


    Right off the bat let me tell you that I'm a C person, so please bear with me. I need to delve into VB world for a little bit so I'd appreciate your help.

    I'm trying to understand if it's possible to reformat the following:
    Code:
    a = 1
    if a = 0 then
        b = 1
    elseif a = 1 then
        b = 2
    else
        b = 3
    end if
    into a single-line statement using colons?

    When I try it, any of the following fail:
    Code:
    a = 1 : if a = 0 then b = 1 elseif a = 1 then b = 2 else b = 3 : end if
    Code:
    a = 1 : if a = 0 then b = 1 : elseif a = 1 then b = 2 else b = 3 : end if
    PS. In case you're curious why I need this -- it will save me time and space to insert code like that as a single-line script into HTML/ASP event handlers instead of starting separate <script> blocks. So please don't start a discussion over this point.

    Thank you.

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,330

    Re: Quick VBScript question

    You would need to write it more like this to get it to work on a single line

    Code:
    a = 0: If a = 0 Then b = 1 Else If a = 1 Then b = 2 Else b = 3
    Last edited by DataMiser; May 20th, 2009 at 02:03 AM.

  3. #3
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    894

    Re: Quick VBScript question

    That would do. Thanks!

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)