Pat S
October 2nd, 2001, 09:11 AM
I need to change this line of code to accept either 7 or 9. Any suggestions?
Dim strSaveSiteNumber As String * 7
Dim strSaveSiteNumber As String * 7
|
Click to See Complete Forum and Search --> : varible Pat S October 2nd, 2001, 09:11 AM I need to change this line of code to accept either 7 or 9. Any suggestions? Dim strSaveSiteNumber As String * 7 Cakkie October 2nd, 2001, 09:18 AM 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 slisse@planetinternet.be 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 Clearcode October 2nd, 2001, 09:29 AM 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. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |