• Welcome to Valhalla Legends Archive.
 

Getting ping from module....

Started by GoSu_KaOs, April 18, 2005, 05:02 PM

Previous topic - Next topic

GoSu_KaOs

I got a problem with this. I need to get the ping, username, all that stuff from the module to Form1. My module looks like this:


Public Function DispatchMessage(ByVal databuf As String)

Dim EID As Long, Ping As Long, Username As String, message As String, Client As String, STATS As Long
EID = MakeLong(Mid$(databuf, 5, 4))
flags = MakeLong(Mid$(databuf, 9, 4))
Ping = MakeLong(Mid$(databuf, 13, 4))
Username = KillNull(Mid$(databuf, 29))
message = KillNull(Mid$(databuf, Len(Username) + 30))

If EID = lasteid And flags = lastflags And Ping = lastping And Username = lastusername And message = lastmessage Then Exit Function
lasteid = MakeLong(Mid$(databuf, 5, 4))
lastflags = MakeLong(Mid$(databuf, 9, 4))
lastping = MakeLong(Mid$(databuf, 13, 4))
lastusername = KillNull(Mid$(databuf, 29))
lastmessage = KillNull(Mid$(databuf, Len(Username) + 30))

Select Case EID

Case ID_JOIN
AddChat vbRed, Username & " has joined the channel with "  & Ping & "."

Case ID_USER
'blabla

Case ..ex.....
_______________________



The problem is, I want to display the ping and username in Form1.
When I do this:


Private Sub cmdGetUsernameAndPing_Click()
AddC vbRed, Module2.DispatchMessage(Username)
AddC vbRed, Module2.DispatchMessage(Ping)
End Sub

'I also tryed this:

Private Sub cmdGetUsernameAndPing_Click()
AddC vbRed, Username
AddC vbRed, Ping
End Sub


Neither way works. I just get a blank message.

What am I doin wrong?

The-FooL

In your first example, you can't call a function like that and expect it to return a variable from inside the function.  I have no idea what you think your doing.

As for the second example, if you work declare the variables in your module Global it should work.  But that really is not the way you should go about accomplishing whatever the hell it is your trying to do.

Yegg

I'm not sure how your code is supposed to work or what Form1 looks like, but can't you just declare the ping and the username, etc. as a public variable so it can be used it both the module and the form? Maybe you could even add them to ListBox's. Add a username to a list, its ping to a list, its flags to a list, etc. You would need a different ListBox for each piece of data, one for ping one for flags, for username, etc. FlagsList(0), PingList(0), UserList(0), etc. would all be for the same username. FlagsList(1), PingList(1), and so on would also be for the same username. I think you get the point. After the user has been added to Form1, if it is necessary you could just remove them from the list. Hope this helps.

GoSu_KaOs

Quote from: The-FooL on April 18, 2005, 05:06 PM
In your first example, you can't call a function like that and expect it to return a variable from inside the function.  I have no idea what you think your doing.

As for the second example, if you work declare the variables in your module Global it should work.  But that really is not the way you should go about accomplishing whatever the hell it is your trying to do.

I'm trying to get the ping of the username that is in a listview. I wasnt clear int eh first post.
I need this: When I click on Command1, the ping of the selected username is shown. The username would be in a listview or textbox.

The-FooL

You won't be able to get the ping from the userjoin sub like that.  You will need to store the ping of the user in the list when you add them.  Then, in your getUsernameAndPing sub, find the selected user in the list and get the ping.

Networks

I am sorry, I just have to laugh at that...(chuckle). *sigh* Anyhow, I suggest you read a VB6 book or something because it's evident you don't know the language. I am not going to help you on this particular thing because you're going to end up coming back a million more times. So I suggest you learn your language.

GoSu_KaOs

#6
If you get me a book named "Making a  bot for Battle.net" and I'll never come back here again. If you're not gonna help, don't post.

Yegg

Learning a language to make a bot is meaningless.

QwertyMonster

Gosu_kaos:


Case &HF
Ping = blah blah

Display me, vbGreen, Ping



In your Form1. Simple.

Hdx

Well, what you could do, Is simply store the Ping somewhere in the listview. AE the .tag attribute. Each object in a list view has it's own .Tag, jsut like it's own .Text. So start using it!
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Warrior

Or store the users in an array with other information (ping, flags, last talk time, etc..) which in the long run would prove to be more helpful.
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?

Yegg

Correct me if I'm wrong. But wouldn't that be pretty similar to if you used a ListBox for the job? An array would be faster but earlier I suggested a ListBox and I guess he didn't do that.

Eric

Once coded, a dynamic array would be much simpler, faster and better organized.

Warrior

Yea, a listbox is nasty for storing data which constantly changes.


Consider the following


Public MyArr() as ArrStruct

Public Type ArrStruct
         Entry1 as String
         Entry2 as String
End Type

........


MyArr(SomeIndex).Entry1 = "Omgz"
Quote from: effect on March 09, 2006, 11:52 PM
Islam is a steaming pile of fucking dog shit. Everything about it is flawed, anybody who believes in it is a terrorist, if you disagree with me, then im sorry your wrong.

Quote from: Rule on May 07, 2006, 01:30 PM
Why don't you stop being American and start acting like a decent human?