Valhalla Legends Forums Archive | Battle.net Bot Development | Can you store object names in variables..

AuthorMessageTime
Tass
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  :'(
July 14, 2005, 10:08 AM
Ringo
Im asuming your trying to do this in VB6?
Do you mean:
[code]
Dim Somthing As RichTextBox
Set Somthing = frmForm.RichTextBox
With Somthing
    .Seltext etc etc
End with
[/code]
Im not 100 % sure of your question, but i hope that helps
July 14, 2005, 11:16 AM
Tass
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
July 14, 2005, 11:43 AM
Dyndrilliac
It's called an array. Make an array of the controls with 50 elements a piece, then loop through it.
July 14, 2005, 2:04 PM
UserLoser.
See .Name on your objects
July 14, 2005, 3:18 PM
Tass
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...
July 14, 2005, 7:40 PM
Myndfyr
[quote author=Tass link=topic=12210.msg120715#msg120715 date=1121370040]
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]

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).
July 14, 2005, 8:29 PM
Tass
What do you mean.. show me something please.
July 14, 2005, 8:32 PM
hierholzer
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?
July 14, 2005, 8:53 PM
Tass
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.
July 14, 2005, 8:55 PM
hierholzer
Well to my understanding your just trying to simplify things so you dont have to type so much correct?
July 14, 2005, 8:57 PM
Tass
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.
July 14, 2005, 8:58 PM
hierholzer
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
July 14, 2005, 9:10 PM
Tass
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.
July 14, 2005, 9:26 PM

Search