Tuesday, February 22, 2011

2 Simple VB6 Projects

So I chucked together a few vb6 projects for beginners that were intended for the Mildura Programmers group of Facebook.

First is an example of how to search and replace text inside a string.
Private Sub Command1_Click()
Dim strOrg
Dim strSrch
Dim strReplace
Dim strOutcome
strOrg = Original.Text
strSrch = Search.Text
strReplace = Replace.Text
If InStr(1, strOrg, strSrch) > 0 Then
strOutcome = Replace(strOrg, strSrch, strReplace)
MsgBox strOutcome
End If
End Sub
http://rapidshare.com/files/449320589/str-search-and-replace.rar

Second is a simple Telnet client using Winsock.
Private Sub cmdConnect_Click()
wskConnect.RemoteHost = txtHost.Text
wskConnect.RemotePort = txtPort.Text
wskConnect.Connect
End Sub

Private Sub cmdSend_Click()
wskConnect.SendData (txtInput.Text & vbCrLf)
txtInput.Text = ""
End Sub

Private Sub For...m_Load()
MsgBox "J. Ben Ross :: 2011"
End Sub

Private Sub Form_Unload(Cancel As Integer)
wskConnect.Close
End Sub

Private Sub wskConnect_Close()
lblStatus.Caption = "Disconnected"
End Sub

Private Sub wskConnect_Connect()
lblStatus.Caption = "Connected!"
End Sub

Private Sub wskConnect_DataArrival(ByVal bytesTotal As Long)
Dim strData As String
wskConnect.GetData strData, vbString
    txtPackets.Text = txtPackets.Text & strData & vbCrLf
End Sub

Private Sub wskConnect_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "There was an error"
wskConnect.Close
End Sub

http://rapidshare.com/files/449320563/PrjTelnet.rar

1 comment:

  1. fuck i was a shit programmer lol, ill leave this post here as a reminder of what not to be

    ReplyDelete