Some VB help if possible

Questions about programming languages and debugging
Post Reply
srock0
Newbie
Newbie
Posts: 3
Joined: 23 Dec 2010, 20:30
13

Some VB help if possible

Post by srock0 »

I have this little task that should be completed by using VB winsocket to create a so called storage system which show and updates the customer balance ( like a bank )

Task looks like this: http://pastie.org/1395884" onclick="window.open(this.href);return false;

I am not requesting a full solution, but if you got some experience and would like to share abit of your knowledge would be appreciated. I am currently tryin' to do it by my own, so I will post my progress very soon.

Thanks in advance

Keyman

srock0
Newbie
Newbie
Posts: 3
Joined: 23 Dec 2010, 20:30
13

Re: Some VB help if possible

Post by srock0 »

here's the two client, but might need some help with the servers.

‘ Some Global variables are required before the subroutines are defined:

Private current as Long
Private Port_address As Long

Dim Ports(5) as integer
Dim Loaded(5) as integer






‘When the server form is loaded:

Private Sub Form_Load()

Dim i as integer

Port_address = 1001
tcpServer(0).LocalPort = port_address
tcpServer(0).Listen
frmclient1.show
frmclient2.show
for i = 1 to 5
Ports(i) = 0
Loaded(i) = 0
Next i

End Sub



‘ When a connection request is received from a client:

Private Sub tcpServer_ConnectionRequest(Index As Integer, ByVal requestID As Long)

Dim new_port_address as integer
Dim i as integer

If Index = 0 Then
i = 0
do
i = i+1
loop while (ports(i) <>0)

ports(i) = 1
new_port_address = port_address + i
if loaded(i) = 0 then load tcpserver(i)
tcpserver(i).localport = new_port_address
tcpserver(i).accept requestID
loaded(i) = 1
end if
end sub


Private Sub txtOutput_Change()
tcpServer(current).SendData txtOutput.text
End sub

Private Sub tcpserver_DataArrival(index As Integer, ByVal bytestotal As Long)
Dim strdata As String
tcpServer(index).GetData strData
txtInput.Text = strData
current = index
End Sub


Private sub command1_click()
Tcpserver(current).close
Ports(current) = 0
End sub

This talk system assumes that the client initiates the communication and the server replies.

The client code is basically the same for two client forms

Post Reply