|
-
Aug 10th, 2010, 01:16 PM
#1
Thread Starter
Junior Member
Display 2 data in listview control using winsock...
ANYONE HELP?
THIS THE CODE
CLIENT:
WINSOCK.SENDDATA = LOCALNAME
WINSOCK.GETDATA = LOCALIP
SERVER DATA ARRIVAL EVENT: ???
WHAT CODE WILL I USE TO SEPARATE THE DATA CAME FROM THE CLIENT USING LISTVIEW CONTROL....
LIKE THIS ONE
[PCNAME]FIRST COLUMN IN LISTVIEW CONTROL
[IPADD]SECOND COLUMN IN LISTVIEW CONTROL
WHAT THE SOURCE CODE FOR THIS PROBLEM...
PLEASE I'M IN RUSH COZ I'M USING IT AS A THESIS
THANK..
"Program KiRa"
-
Aug 10th, 2010, 01:50 PM
#2
Re: Display 2 data in listview control using winsock...
Here''s what you need to do.
Step 1, turn off caps lock. This part is essential for the code to work.
Step 2
WHAT CODE WILL I USE TO SEPARATE THE DATA CAME FROM THE CLIENT USING LISTVIEW CONTROL....
ListView can't do or separate anything on it's own, it can only display what you tell it to. You will have to sort the data yourself before you 'give' it to the ListView. Doing that depends on the format and structure of the data you are receiving, but most likely you will be doing it using standard string manipulation functions (Split, InStr, Left$, Right$, Mid$, Len...)
Regarding ListView display style, right click on it in Design mode, go to Properties, change the View to Report style, and add two Columns to it. Then you can use code like this to add items to it:
Code:
ListView1.ListItems.Add, , "Sample text in column 1"
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add, , "Item in col 2"
Last edited by baja_yu; Aug 10th, 2010 at 01:53 PM.
-
Aug 10th, 2010, 02:06 PM
#3
Thread Starter
Junior Member
Re: Display 2 data in listview control using winsock...
oh sorry about the capslock...
thanks for the idea....i almost got the listview properties...thx
in the data arrival event what code will i use to split the data?
-
Aug 10th, 2010, 02:10 PM
#4
Re: Display 2 data in listview control using winsock...
oh sorry about the capslock...
Don't worry about it 
Depends on how the data is formated. Post an example of the raw data you get and I'll help you with extracting data from it.
For example, if you get "somename/someip" you could simply use Split function passing "/" as the token.
-
Aug 10th, 2010, 02:22 PM
#5
Thread Starter
Junior Member
Re: Display 2 data in listview control using winsock...
ok like this one.....
'the client will send the name and ip of the PC
Private Sub cmdSend_Click()
Dim PC As String
Dim IP As String
PC = SckUDP.LocalHostName
IP = SckUDP.LocalIP
SckTCP.SendData PC & "|" & IP
'then the server will recieve the MSG
Private Sub SckTCP_DataArrival(ByVal bytesTotal As Long)
Dim MSG As String
SckTCP.GetData MSG, vbString
"whats next?"
the ouptut should be like this:
ListView1.ListItems.Add = PCname
ListView1.ListItems.subitems(1) = IPaddress
what am i gonna do?
-
Aug 10th, 2010, 02:49 PM
#6
Re: Display 2 data in listview control using winsock...
What is the exact data you get back?
What would be displayed if you did
MsgBox MSG
after the GetData call?
If I'm correct you are making the server and client app, and the client is sneding the name and IP with this: SckTCP.SendData PC & "|" & IP
Then the server is receiving it with: SckTCP.GetData MSG, vbString
If that's correct the server would receive a string like this: SomeName|127.0.0.1, for example. If that is so, you can do this after the GetData call
Code:
Dim strRecData () As String
strRecData = Split(MSG, "|")
ListView1.ListItems.Add, , strRecData(0) 'name
ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add, , strRecData(1) 'IP
-
Aug 11th, 2010, 02:34 AM
#7
Thread Starter
Junior Member
Re: Display 2 data in listview control using winsock...
hmmm, gonna check this out.... thx
-
Aug 11th, 2010, 02:41 AM
#8
Thread Starter
Junior Member
Re: Display 2 data in listview control using winsock...
it works thanks a lot oh btw, is this can be used as vice versa?
like client to server and server to client?
-
Aug 11th, 2010, 02:45 AM
#9
Thread Starter
Junior Member
Re: Display 2 data in listview control using winsock...
oh i forgot something, when the client is disconnected
what code will i used to refresh the listview control...?
like this...
when the client was disconnected,
the client will disappeared from the listview of the server....
is it possible?
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
|