Re: Distinguishing variables
Moved From The CodeBank (which is for sharing code rather than posting questions :) )
Re: Distinguishing variables
Since programs normally don't have any reason to "look at themselves" there isn't really anything built in to support it.
If you simply want to associate a bunch of variables with a bunch of controls you might consider using data arrays and control arrays.
Re: Distinguishing variables
I think what he's looking for is the TypeName-Function or the TypeOf-Operator, but i doubt it's going to work on an entry in a textbox since the Text-Property per se returns a string.
What he might try is
IsNumeric, IsDate, but i haven't found anything like IsText or similiar
Re: Distinguishing variables
I think this just a question about Arrays, it's not very clear.
Code:
Option Explicit
Private strTypes(2) As String
Private strNames(2) As String
Private Sub Command_Click()
Dim intI As Integer
txtAnswer.Text = vbNullString
If txtWord.Text <> vbNullString Then
Do
If UCase(strTypes(intI)) = UCase(txtWord.Text) Then
txtAnswer.Text = strNames(intI)
Else
intI = intI + 1
End If
Loop Until intI > UBound(strTypes) Or txtAnswer.Text <> vbNullString
End If
End Sub
Private Sub Form_Load()
'
' List of Types
'
strTypes(0) = "Land"
strTypes(1) = "Sea"
strTypes(2) = "Air"
'
' List of Names
'
strNames(0) = "England"
strNames(1) = "Atlantic Ocean"
strNames(2) = "Cloud"
End Sub
Re: Distinguishing variables
I was thinking Dictionary myself... or rather a Collection where the key is the "type" (eg, Land) and the value would be the corresponding name.
I'd provide a sample but I don't have VB6 on this machine.
-tg
Re: Distinguishing variables
Quote:
Originally Posted by
ITbanter2k12
Hope I've been clear enough and I hope you can help.
Well, asking this question and getting 4 different answers should give you a clue.....