Tobyn
Nov 4th, 1999, 09:28 PM
how might i make
X = 1 thru 100
so that it would check something like this
bah1
bah2
bah3
bah4
bah5
etc..
so that i dont have to type in like 100 lines of code instead of just one or 2?
any suggestions?
thanks,
Tobyn
Aaron Young
Nov 4th, 1999, 09:46 PM
I'm not sure what you're asking, but if you want X to be in a Range of 1 to 100, then use the And Operator in you Conditions, eg.
If X > 0 And X < 101 Then Msgbox "X is In the Range 1 To 100!"
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
Tobyn
Nov 4th, 1999, 10:14 PM
actually,
i was looking at doing something like this
Dim CountClick As Integer
Dim X As Variant
Private Sub cmdOK_Click()
X = 0 + Label1.Caption
X = 1 Or "2" Or 3 Or 4 Or 5 Or 6 Or 7 Or 8 Or 9 Or 10
Dim bLoggedin As Boolean
If txtuser.Text = GetAllSettings(App.Title, "Setup") And txtpass.Text = GetSetting(App.Title, "Setup", "pass1") Then
bLoggedin = True
ElseIf txtuser.Text = GetSetting(App.Title, "Setup", "user" & X) And txtpass.Text = GetSetting(App.Title, "Setup", "pass2" & X) Then
bLoggedin = True
ElseIf txtuser.Text = GetSetting(App.Title, "Setup", "User3") And txtpass.Text = GetSetting(App.Title, "Setup", "Pass3") Then
bLoggedin = True
ElseIf txtuser.Text = GetSetting(App.Title, "Setup", "user4") And txtpass.Text = GetSetting(App.Title, "Setup", "pass4") Then
bLoggedin = True
ElseIf txtuser.Text = GetSetting(App.Title, "Setup", "user5") And txtpass.Text = GetSetting(App.Title, "Setup", "pass5") Then
bLoggedin = True
ElseIf txtuser.Text = GetSetting(App.Title, "Setup", "user6") And txtpass.Text = GetSetting(App.Title, "Setup", "pass6") Then
bLoggedin = True
ElseIf txtuser.Text = GetSetting(App.Title, "Setup", "user7") And txtpass.Text = GetSetting(App.Title, "Setup", "pass7") Then
bLoggedin = True
ElseIf txtuser.Text = GetSetting(App.Title, "Setup", "user8") And txtpass.Text = GetSetting(App.Title, "Setup", "pass8") Then
bLoggedin = True
Else
bLoggedin = False
End If
accepeted:
MsgBox IIf(bLoggedin, "Login Successful", "Login Failed")
End Sub
Private Sub Command1_Click()
CountClick = Label1.Caption + 1
SaveSetting App.Title, "Setup", "User" & CountClick, Text1
SaveSetting App.Title, "Setup", "Pass" & CountClick, Text2
Label1.Caption = CountClick
Label2.Caption = CountClick
End Sub
Private Sub exit_Click()
SaveSetting App.Title, "setup", "User#", CountClick
SaveSetting App.Title, "setup", "Pass#", CountClick
End
End Sub
Private Sub Form_Load()
Label1.Caption = GetSetting(App.Title, "setup", "User#")
Label2.Caption = GetSetting(App.Title, "setup", "Pass#")
End Sub
i don't think this works right, there must be a way not to have to right 100 + lines of code
thanks,
Tobyn
Justice
Nov 4th, 1999, 10:15 PM
Sounds like you want to make the variable 'X' equal to a range of numbers from 1 to 100. VB can't do that. You CAN do this by using code similar to this:
For X = 1 to 100
'Your code here
Next X
Within this X starts out equal to 1 and each time it goes through it'll be equal to the next value (1,2,3,etc).
Hope this helps.
Justice
Nov 4th, 1999, 10:17 PM
CORRECTION:
VB CAN make a variable equal to a range of numbers if you write a specific function or (even better) make 'X' an OBJECT and assign it a RANGE property.