|
-
October 2nd, 2001, 09:11 AM
#1
varible
I need to change this line of code to accept either 7 or 9. Any suggestions?
Dim strSaveSiteNumber As String * 7
-
October 2nd, 2001, 09:18 AM
#2
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
-
October 2nd, 2001, 09:29 AM
#3
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|