Orginally posted by 22367rh
There are 2 things I must say before I begin: 1) This is my first tutorial & it is pretty basic. 2) Most people here can probably do this anyway.
Now on to the tutorial :-).
Server Side:
File: frmServer What to do: a) Add 2 Textboxes called txtBytesSent and txtBytesRecieved. b) Add a 4 New Menu Items named mnuBytes, mnuKB, mnuMB, mnuGB (with the captions set to Bytes, Kilobytes, Megabytes, Gigabytes) c) Double Click "Socket" & go to the Data_Arrival section. Add This Code just before the End Sub:
BR.Bytes = BR.Bytes + bytesTotal BR.KBytes = BR.Bytes / 1024 BR.MBytes = BR.KBytes / 1024 BR.GBytes = BR.MBytes / 1024 DisplayBytesRecieved d) Stay in the "Socket" area & now go to Send_Progress. Add This Code in there:
BS.Bytes = BS.Bytes + bytesSent BS.KBytes = BS.Bytes / 1024 BS.MBytes = BS.KBytes / 1024 BS.GBytes = BS.MBytes / 1024 DisplayBytesSent e) Add This Code at the end of frmServer:
Private Sub mnuBytes_Click() ByteMeasure = "Bytes" UncheckAllMeasurements mnuBytes.Checked = True DisplayBytesRecieved DisplayBytesSent End Sub
Private Sub mnuGB_Click() ByteMeasure = "GigaBytes" UncheckAllMeasurements mnuGB.Checked = True DisplayBytesRecieved DisplayBytesSent End Sub
Private Sub mnuKB_Click() ByteMeasure = "KiloBytes" UncheckAllMeasurements mnuKB.Checked = True DisplayBytesRecieved DisplayBytesSent End Sub
Private Sub mnuMB_Click() ByteMeasure = "MegaBytes" UncheckAllMeasurements mnuMB.Checked = True DisplayBytesRecieved DisplayBytesSent End Sub
File: modBytes &nbs p; ** NEEDS CREATING ** What to do: a) Add This Code Into It:
Public BS As BytesType Public BR As BytesType
Public ByteMeasure As String
Public Type BytesType Bytes As Long KBytes As Long MBytes As Long GBytes As Long End Type
Public Function DisplayBytesRecieved() Dim frm As frmServer frmServer.txtBytesRecieved.Text = "" If ByteMeasure = "Bytes" Then frmServer.txtBytesRecieved.Text = BR.Bytes & " B" ElseIf ByteMeasure = "KiloBytes" Then frmServer.txtBytesRecieved.Text = BR.KBytes & " KB" ElseIf ByteMeasure = "MegaBytes" Then frmServer.txtBytesRecieved.Text = BR.MBytes & " MB" Else 'ByteMeasure = "GigaBytes" frmServer.txtBytesRecieved.Text = BR.GBytes & " GB" End If End Function
Public Function DisplayBytesSent() frmServer.txtBytesSent.Text = "" If ByteMeasure = "Bytes" Then frmServer.txtBytesSent.Text = BS.Bytes & " B" ElseIf ByteMeasure = "KiloBytes" Then frmServer.txtBytesSent.Text = BS.KBytes & " KB" ElseIf ByteMeasure = "MegaBytes" Then frmServer.txtBytesSent.Text = BS.MBytes & " MB" Else 'ByteMeasure = "GigaBytes" frmServer.txtBytesSent.Text = BS.GBytes & " GB" End If End Function
Sub UncheckAllMeasurements() frmServer.mnuBytes.Checked = False frmServer.mnuKB.Checked = False frmServer.mnuMB.Checked = False frmServer.mnuGB.Checked = False End Sub
That should be everything. Any problems/comments then just post below.
|