I wana know if you can store object names like RichTextBox or frmMain.Winsock1 into a variable so I don't have to use 50 million If-Then statements in my packet pharsing module..
~Tass Omg plz help me :'(
Im asuming your trying to do this in VB6?
Do you mean:
Dim Somthing As RichTextBox
Set Somthing = frmForm.RichTextBox
With Somthing
.Seltext etc etc
End with
Im not 100 % sure of your question, but i hope that helps
That's kinda what I mean but what if I already have a function like AddC or something.
I wana use something like..
Select case Bot
Case "1"
RTB = RichTextBox1
WinSock = sckWinSock1
Case "2"
RTB = RichTextBox2
WinSock= sckWinSock2
End select
If winSock2.State <> sckDisconnected Then: WinSock2.Disconnect
or something like that
if you can't I'm guessing I'll have to write 50 If-Then statements for my bot instead of taking the easy way out :P
~Tass
It's called an array. Make an array of the controls with 50 elements a piece, then loop through it.
See .Name on your objects
Know of anywhere I can get an array tutorial..?
by the way.. if you use Richtextbox1.name it returns "RichTextBox1" Which is not the same as RichTextBox1...
Quote from: Tass on July 14, 2005, 02:40 PM
Know of anywhere I can get an array tutorial..?
by the way.. if you use Richtextbox1.name it returns "RichTextBox1" Which is not the same as RichTextBox1...
You're correct, but if you know the name of your object is RichTextBox1, you can loop through your controls to find the one
named "RichTextBox1".....
[edit]I didn't want to repost, but I find it intriguing -- the conversation going on below. It's like the blind leading the blind, especially when you consider that I already posted the right answer (as did UserLoser).
What do you mean.. show me something please.
Well I know of Parallel arrays. which are two arrays working side by side. Which means each element in one array corresponds to an element in the other array. Are you looking for an array like that?
Dunno what I'm really looking for, I'm trying to figure out what I have to do.. that's what I'm trying to figure out.
Well to my understanding your just trying to simplify things so you dont have to type so much correct?
Not that I don't want to type so much I'd just have to copy and paste.. I'd have 3 differen't If-Then statements looking almost exactly the same besides which socket it sends a respond to and the RichTextbox it adds some text too.. seems kinda pointless to do all them If-Then statements.
Here is an example out of a Vb book I have that uses Arrays Ill type it out for you and you fill in the blanks.
(Arrays simplify data storage)
1:Private Sub Association ()
2: ' Procedure to gather and print 35 names and dues
3: Dim strFamilyName(35) As String ' Reserve the array elements
4: Dim curFamilyDues(35) As Currency
5: Dim intSub As Integer
6: Dim intMsg as Interger ' MsgBox() return
7:
8: 'Loop getting all the data
9: For intSub = 1 To 35
10: strFamilyName(intSub) = InputBox("what is the next family's name")
22: Next intSub
23:
24: ' you now can display all the data
25: ' This example uses a series of message boxes simple
26:
27: intSub = 1 ' initialize the first subscript
28: Do
29: intMsg = MsgBox("Family " & intSub & " is " & strFamilyName(intSub))
30: intMsg = MsgBox(:their dues are " & curFamilyDues(intsub))
31: intSub = intSub + 1
32:Loop Until (intsub > 35)
33: End Sub
Thats an example I dont know is ist what your looking for or not
I already have the function I'm trying to send an object name to that function via a variable.. instead of using 4 or so if-thens statements I wana only use one.