用VB实现的代码
文本框里是 11010100 后面是 “开始画” 和“重新画” 两个按钮这是用VB编写的代码:
Private Sub Command1_Click()
Dim l As String
Dim a, b, X, x1, Y, y1 As String
Form2.Cls
l = Text1.Text
a = Len(l)
For b = 1 To a
If Mid(l, b, 1) = "0" Or Mid(l, b, 1) = "1" Or Mid(l, b, 1) = vbCrLf Then
Else
MsgBox "输入错误,请从新输入,只能输入0和1!", , "错误提示"
Text1.Text = ""
End If
Next b
If Text1.Text = "" Then
Form1.Cls
Else
Line (Form2.Width / 30, 5.5 * Form2.Height / 10)-(Form2.Width / 20 * (a + 2), 5.5 * Form2.Height / 10), RGB(250, 0, 0)
Line (Form2.Width / 20 * (a + 2), 5.5 * Form2.Height / 10)-(Form2.Width / 20 * (a + 2) - 100, 5.5 * Form2.Height / 10 - 50), RGB(250, 0, 0)
Line (Form2.Width / 20 * (a + 2), 5.5 * Form2.Height / 10)-(Form2.Width / 20 * (a + 2) - 100, 5.5 * Form2.Height / 10 + 50), RGB(250, 0, 0)
CurrentX = Form2.Width / 20 * (a + 2)
CurrentY = 5.6 * Form2.Height / 10
Print "时间"
Line (Form2.Width / 20, 7.5 * Form1.Height / 10)-(Form2.Width / 20, 3.5 * Form2.Height / 10), RGB(250, 0, 0)
Line (Form2.Width / 20 - 50, 3.5 * Form2.Height / 10 + 100)-(Form2.Width / 20, 3.5 * Form2.Height / 10), RGB(250, 0, 0)
Line (Form2.Width / 20 + 50, 3.5 * Form2.Height / 10 + 100)-(Form2.Width / 20, 3.5 * Form2.Height / 10), RGB(250, 0, 0)
CurrentX = 1.1 * Form2.Width / 20
CurrentY = 3.5 * Form2.Height / 10
Print "电压"
For b = 1 To a + 1
Line (b * Form2.Width / 20, 5.5 * Form2.Height / 10)-(b * Form2.Width / 20, 5.5 * Form2.Height / 10 - 80)
Next b
x1 = Form2.Width / 20
y1 = 5.5 * Form2.Height / 10
For b = 1 To a
If Mid(l, b, 1) = "0" Then
Y = 4.5 * Form2.Height / 10
Else
Y = 6.5 * Form2.Height / 10
End If
X = Form2.Width / 20 * b
Line (x1, y1)-(X, Y), RGB(0, 0, 255)
Line (X, Y)-(X + Form2.Width / 20, Y), RGB(0, 0, 255)
x1 = X + Form2.Width / 20
y1 = Y
Next b
End If
End Sub
Private Sub Command2_Click()
Form2.Cls
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Form2_Resize()
Call Command1_Click
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Call Command1_Click
End Sub