|
-
Aug 15th, 2000, 10:04 AM
#1
Thread Starter
Hyperactive Member
Heres what I need to do , Keep track of a name and an index number in a server application . I tried at first to do it in a text file , but I found it to hard to to parse the text and just plain complicated . "but heh is'nt it all?"
Ok so I then thought I could store it in an array , but I dont know much about them . So I read a bit . It sounds like it'll work but Im not sure How to implement it . So I tried to make my own (Type) I did this in a .bas module . Is it right?
In general Declare
-----------------------
Public Type usrArray
sTemp As String
iCount As Integer
End Type
Dim allusers(1 To 10) As usrArray
---------------------
Public Sub addUser(socknum As Integer, nick As String)
usrCounter = usrCounter + 1
allusers(usrCounter).sTemp = "nick"
allusers(usrCounter).iCount = socknum
msgbox allusers(usrCount)
End Sub
---------------------
I was hoping that
----------------------
Public Type usrArray
sTemp As String
iCount As Integer
End Type
Dim allusers(1 To 10) As usrArray
----------------------
would give me an array of 10 items each containing a string and an integer . Back in the main form at the event I put
Call addUser(index, nick) and I Get an Error saying Only user defined types defined in public modules can be coherced to or from a a variant but its supposed to be an array ? So Im confused .
Is someone willing to attempt to explain to me what I need to understand and fix this Problem ?
Once again Im trying to sore a string and a number in an array that I can increase in size to match the number of people on the server .
Thanks ,
[]PRIVATE
[Edited by PRIVATE1 on 08-15-2000 at 11:09 AM]
-
Aug 15th, 2000, 10:14 AM
#2
Fanatic Member
Put the Type declaration in the Module not in the General Declarations of the form.
It should help
-
Aug 15th, 2000, 10:16 AM
#3
Thread Starter
Hyperactive Member
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Aug 15th, 2000, 10:22 AM
#4
here this might help a little....
ok ok. I went a little overboard
Code:
Private Type usrArray
sTemp As String
iCount As Integer
End Type
Dim usr() As usrArray
Dim TheCount As Integer
Dim i As Long
Private Sub AddUser(SockNum As Integer, Nick As String)
ReDim Preserve usr(TheCount)
usr(TheCount).iCount = SockNum
usr(TheCount).sTemp = Nick
TheCount = TheCount + 1
End Sub
Private Sub Command1_Click()
Call AddUser(1, "Dennis")
For i = 0 To UBound(usr) - 1
MsgBox usr(i).iCount
MsgBox usr(i).sTemp
Next
End Sub
-
Aug 15th, 2000, 10:27 AM
#5
Thread Starter
Hyperactive Member
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Aug 17th, 2000, 07:24 AM
#6
Thread Starter
Hyperactive Member
How can I check to see if the new
usr(TheCount).sTemp = Nick
is in the array already ?
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
|