发布网友 发布时间:2024-10-23 05:16
共2个回答
热心网友 时间:2024-10-24 01:42
你先找一下VB串口通信的基本程序,随便发一个数看单片机能不能接到。如果能接到的话就在VB界面添加两个按钮控件,点其中一个发一个数,点另一个发另一个数,这个数你随便设,只要单片机能够判断不一样就能控制继电器都通断了。
热心网友 时间:2024-10-24 01:42
Option ExplicitPrivate Sub Command1_Click() Dim n(7) As Double Dim k(3) As Double k(3) = 1 Dim j As Integer For j = 1 To 7 n(j) = Val(Controls("Text" & CStr(j)).Text) Next j For j = 1 To 7 k(1) = k(1) + n(j) k(2) = k(2) - n(j) k(3) = k(3) * n(j) Next j Me.Text8.Text = "7个数的和为:" & k(1) & vbCrLf & _ "7个数的差为:" & k(2) & vbCrLf & _ "7个数的乘积为:" & k(3)End SubPrivate Sub Command2_Click() Dim i As Integer For i = 1 To 8 Controls("Text" & CStr(i)).Text = "" Next iEnd SubPrivate Sub Form_Load() Dim i As Integer For i = 1 To 8 Controls("Text" & CStr(i)).Text = "" Next iEnd Sub