最后一个大的馅饼咯,o(∩_∩)o...哈哈
Private Sub btnWrite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWrite.Click
Dim wData As Byte
Dim nPort As Integer = Integer.Parse(cbPort.Text)
If txtWrite.Text <> "" Then
If 2 = txtWrite.Text.Length Then
Dim first_Ch As Char = Convert.ToChar(txtWrite.Text.Substring(0, 1))
Dim second_Ch As Char = Convert.ToChar(txtWrite.Text.Substring(1, 1))
Dim first_Num As Integer = Ascii2Hex(first_Ch)
Dim second_Num As Integer = Ascii2Hex(second_Ch)
If first_Num >= 0 AndAlso second_Num >= 0 Then
wData = Byte.Parse(Convert.ToString(first_Num * 16 + second_Num))
wData = wData And data_Mark
WritePort(nPort, wData)
Else
MsgBox("Please input 00~FF.")
txtWrite.Text = "0"
End If
End If
If 1 = txtWrite.Text.Length Then
Dim last_num As Integer = Ascii2Hex(Convert.ToChar(txtWrite.Text.Substring(0, 1)))
If last_num >= 0 Then
wData = Byte.Parse(Convert.ToString(last_num))
wData = wData And data_Mark
WritePort(nPort, wData)
Else
MsgBox("Please input 00~FF.")
txtWrite.Text = "0"
End If
End If
Else
txtWrite.Text = "0"
MsgBox("Please input 00~FF.")
End If
End Sub
转成VC++.net奉上60分。