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

Thread: varible

  1. #1
    Join Date
    Sep 2001
    Location
    South Dakota
    Posts
    20

    varible

    I need to change this line of code to accept either 7 or 9. Any suggestions?

    Dim strSaveSiteNumber As String * 7


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: varible

    I'm affraid you can't declare variables with multiple lengths. What you probably can only do is to declare it variable length, and check the length when assigning a value to it

    Dim str7or9 as string

    Select Case len(Text1.Text)
    Case 7, 9
    str7Or9 = Text1.Text
    Case else
    Msgbox "Length must be 7 or 9"
    End Select




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: varible

    This is a candidate for properties...


    'in a class or form file...
    private mMyString as string

    public property get MyString() as string
    MyString = mMyString
    End property

    public property let MyString(byval newStr as string)

    If len(newStr) = 7 or len(newStr) = 9 then
    mMyString = newStr
    else
    Err.Raise vbOjectError , "MyStr can only be 7 or 9 chars long"
    End If
    End property





    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

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

Featured