hi, i bought a Programmable Message Board kit, this kit connects to the computer and i can send from the computer massages to the kit LCD screen.
I got an sample file, that comes with that kit.
My problem is that this sample file are an old Visual Basic 6 project file, i tried to upgrade it to VB 2008 (Using the Upgrade wizard), its worked, but still there are some errors which i cannot solve :( (I'm just a beginner in VB.net).
Somebody can help me with this file?
Here is the code of the sample, that i tried to upgrade:
Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class text_to_RS232
Inherits System.Windows.Forms.Form
Dim flag As Boolean 'flag = false : send ID, flag = true : send data
Dim ID As String 'will contain ID address
Dim messagestring As String 'will contain all messages to transmit
Dim charcounter As Short 'will keep track of the position in messagestring
Dim inputtrigger(10) As String 'will keep track of trigger status (1 or 0)
Dim message(10) As String 'will keep track of message content
Dim inputnumber(10) As String 'will keep track of input #
Dim port As String 'keeps serial port #
Dim trigger(10) As Boolean
'UPGRADE_WARNING: Event Combo1.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
'UPGRADE_WARNING: ComboBox event Combo1.Change was upgraded to Combo1.TextChanged which has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="DFCDE711-9694-47D7-9C50-45A99CD8E91E"'
Private Sub Combo1_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Combo1.TextChanged
Dim None As Object
If comm.PortOpen = True Then comm.PortOpen = False
port = Combo1.Text
comm.CommPort = Val(Combo1.Text)
'UPGRADE_WARNING: Couldn't resolve default property of object None. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
comm.Handshaking = None
comm.Settings = "2400,N,8,1"
comm.OutBufferSize = 4096
comm.InputLen = 0
comm.RThreshold = 1
comm.SThreshold = 1
comm.PortOpen = True
End Sub
'UPGRADE_WARNING: Event Combo1.SelectedIndexChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
Private Sub Combo1_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Combo1.SelectedIndexChanged
Dim None As Object
If comm.PortOpen = True Then comm.PortOpen = False
port = Combo1.Text
comm.CommPort = Val(Combo1.Text)
'UPGRADE_WARNING: Couldn't resolve default property of object None. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
comm.Handshaking = None
comm.Settings = "2400,N,8,1"
comm.OutBufferSize = 4096
comm.InputLen = 0
comm.RThreshold = 1
comm.SThreshold = 1
comm.PortOpen = True
End Sub
'UPGRADE_WARNING: Event Combo2.SelectedIndexChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
Private Sub Combo2_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Combo2.SelectedIndexChanged
ID = Combo2.Text
End Sub
Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click 'cursor home
flag = False
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
messagestring = Chr(8)
charcounter = 1
Timer1.Enabled = True
End Sub
Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click 'send to LCD
flag = False
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
messagestring = Text1.Text
charcounter = 1
Timer1.Enabled = True
End Sub
Private Sub Command3_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command3.Click 'clear LCD
flag = False
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
messagestring = Chr(13)
charcounter = 1
Timer1.Enabled = True
End Sub
Private Sub Command4_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command4.Click 'date and time
flag = False
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
messagestring = Chr(13) & " " & DateString
charcounter = 1
Timer1.Enabled = True
End Sub
Private Sub Command5_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command5.Click 'time
flag = False
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
messagestring = Chr(13) & " " & VB.Left(TimeString, 5)
charcounter = 1
Timer1.Enabled = True
End Sub
Private Sub Command6_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command6.Click 'clear textbox
Text1.Text = ""
End Sub
Private Sub Command7_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command7.Click
MsgBox("Make sure K8045 is in 'program mode' (press SW2)")
flag = False
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
messagestring = "S" & ID & "QQQQQQ" & Chr(13)
charcounter = 1
Timer1.Enabled = True
End Sub
Private Sub text_to_RS232_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
Dim t As Object
flag = False
For t = 0 To 9
'UPGRADE_WARNING: Couldn't resolve default property of object t. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
Combo2.Items.Add((Str(t)))
Next t
Combo2.Text = VB6.GetItemString(Combo2, 0)
ID = "0"
Timer1.Enabled = False
On Error GoTo no_port
comm.CommPort = CShort("1")
comm.PortOpen = True
Combo1.Items.Add("1")
comm.PortOpen = False
comm.CommPort = CShort("2")
comm.PortOpen = True
Combo1.Items.Add("2")
comm.PortOpen = False
comm.CommPort = CShort("3")
comm.PortOpen = True
Combo1.Items.Add("3")
comm.PortOpen = False
comm.CommPort = CShort("4")
comm.PortOpen = True
Combo1.Items.Add("4")
comm.PortOpen = False
Exit Sub
no_port:
Combo1.Text = VB6.GetItemString(Combo1, 0)
Exit Sub
End Sub
'UPGRADE_NOTE: Form_Terminate was upgraded to Form_Terminate_Renamed. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A9E4979A-37FA-4718-9994-97DD76ED70A7"'
'UPGRADE_WARNING: text_to_RS232 event Form.Terminate has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
Private Sub Form_Terminate_Renamed()
If comm.PortOpen = True Then comm.PortOpen = False
End Sub
'UPGRADE_WARNING: Event Text1.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
Private Sub Text1_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Text1.TextChanged 'tekstbox
'aaa
End Sub
Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
If flag = False Then GoTo sendID
comm.Output = Mid(messagestring, charcounter, 1)
charcounter = charcounter + 1
If charcounter = Len(messagestring) + 1 Then Timer1.Enabled = False
flag = False
If Timer1.Enabled = False Then Me.Cursor = System.Windows.Forms.Cursors.Default
Exit Sub
sendID:
comm.Output = ID
flag = True
End Sub
End Class
The Original File (Visual Basic 6 Version):
Dim flag As Boolean 'flag = false : send ID, flag = true : send data
Dim ID As String 'will contain ID address
Dim messagestring As String 'will contain all messages to transmit
Dim charcounter As Integer 'will keep track of the position in messagestring
Dim inputtrigger(10) As String 'will keep track of trigger status (1 or 0)
Dim message(10) As String 'will keep track of message content
Dim inputnumber(10) As String 'will keep track of input #
Dim port As String 'keeps serial port #
Dim trigger(10) As Boolean
Private Sub Combo1_Change()
If comm.PortOpen = True Then comm.PortOpen = False
port = Combo1.Text
comm.CommPort = Val(Combo1)
comm.Handshaking = None
comm.Settings = "2400,N,8,1"
comm.OutBufferSize = 4096
comm.InputLen = 0
comm.RThreshold = 1
comm.SThreshold = 1
comm.PortOpen = True
End Sub
Private Sub Combo1_Click()
If comm.PortOpen = True Then comm.PortOpen = False
port = Combo1.Text
comm.CommPort = Val(Combo1)
comm.Handshaking = None
comm.Settings = "2400,N,8,1"
comm.OutBufferSize = 4096
comm.InputLen = 0
comm.RThreshold = 1
comm.SThreshold = 1
comm.PortOpen = True
End Sub
Private Sub Combo2_Click()
ID = Combo2.Text
End Sub
Private Sub Command1_Click() 'cursor home
flag = False
text_to_RS232.MousePointer = 11
messagestring = Chr$(8)
charcounter = 1
Timer1.Enabled = True
End Sub
Private Sub Command2_Click() 'send to LCD
flag = False
text_to_RS232.MousePointer = 11
messagestring = Text1.Text
charcounter = 1
Timer1.Enabled = True
End Sub
Private Sub Command3_Click() 'clear LCD
flag = False
text_to_RS232.MousePointer = 11
messagestring = Chr$(13)
charcounter = 1
Timer1.Enabled = True
End Sub
Private Sub Command4_Click() 'date and time
flag = False
text_to_RS232.MousePointer = 11
messagestring = Chr$(13) & " " & Date$
charcounter = 1
Timer1.Enabled = True
End Sub
Private Sub Command5_Click() 'time
flag = False
text_to_RS232.MousePointer = 11
messagestring = Chr$(13) & " " & Left$(Time$, 5)
charcounter = 1
Timer1.Enabled = True
End Sub
Private Sub Command6_Click() 'clear textbox
Text1.Text = ""
End Sub
Private Sub Command7_Click()
MsgBox ("Make sure K8045 is in 'program mode' (press SW2)")
flag = False
text_to_RS232.MousePointer = 11
messagestring = "S" & ID & "QQQQQQ" & Chr$(13)
charcounter = 1
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
flag = False
For t = 0 To 9
Combo2.AddItem (Str$(t))
Next t
Combo2.Text = Combo2.List(0)
ID = "0"
Timer1.Enabled = False
On Error GoTo no_port
comm.CommPort = "1"
comm.PortOpen = True
Combo1.AddItem "1"
comm.PortOpen = False
comm.CommPort = "2"
comm.PortOpen = True
Combo1.AddItem "2"
comm.PortOpen = False
comm.CommPort = "3"
comm.PortOpen = True
Combo1.AddItem "3"
comm.PortOpen = False
comm.CommPort = "4"
comm.PortOpen = True
Combo1.AddItem "4"
comm.PortOpen = False
Exit Sub
no_port:
Combo1.Text = Combo1.List(0)
Exit Sub
End Sub
Private Sub Form_Terminate()
If comm.PortOpen = True Then comm.PortOpen = False
End Sub
Private Sub Text1_Change() 'tekstbox
'aaa
End Sub
Private Sub Timer1_Timer()
If flag = False Then GoTo sendID
comm.Output = Mid$(messagestring, charcounter, 1)
charcounter = charcounter + 1
If charcounter = Len(messagestring) + 1 Then Timer1.Enabled = False
flag = False
If Timer1.Enabled = False Then text_to_RS232.MousePointer = 0
Exit Sub
sendID:
comm.Output = ID
flag = True
End Sub
PS: im adding the original files and the converted files.
Thank you, Man1919.