1、将你的这些数据复制到a.txt中,并将其放到d盘根目录。
0 -531
60 -532
120 -532
180 -526
240 -530
300 -532
360 -532
420 -532
480 -532
540 -533
600 -533
660 -535
720 -535
780 -535
840 -535
900 -535
960 -527
1020 -534
1080 -535
1140 -535
1200 -535
1260 -535
1320 -535
1380 -535
1440 -535
1500 -535
1560 -535
1620 -535
1680 -535
1740 -535
1800 -535
1860 -535
1920 -535
1980 -535
2040 -535
2100 -535
2160 -535
2220 -533
2280 -534
2340 -535
2400 -535
2460 -535
2520 -535
2580 -535
2640 -535
2700 -535
2760 -535
2.新建一个标准exe工程,在窗体上画出一个按钮command1,一个标签label1,并将其indix属性设为0
3、将下列代码复制到代码窗口
Private Sub Command1_Click()
Open "D:\a.txt" For Input As #1
'Input #1, x, y
Form1.Line (2, 2)-(2, 2)
Do While Not EOF(1)
Input #1, x, y
Form1.Line -(x / 30 + 2, -(y + 519) * 2), &HFF&
Loop
Close #1
End Sub
Private Sub Form_Load()
Me.AutoRedraw = True
Show
Me.ScaleHeight = 44 '将窗体的高设定为44份
Me.ScaleWidth = 50 '将窗体的宽设定为50份
'Me.Line.BorderColor = &H0&
Me.Line (2, 2)-(2, 42), &H0& '画出纵坐标
Me.Line (2, 2)-(48, 2), &H0& '画出横坐标
Me.Line (48, 2)-(47.5, 1.5), &H0& '画出横坐标上的箭头
Me.Line (48, 2)-(47.5, 2.5), &H0&
Me.Line (2, 42)-(1.75, 41), &H0& '画出纵坐标上的箭头
Me.Line (2, 42)-(2.25, 41), &H0&
Label1(0).Width = 20 '写出坐标原点
Label1(0).Height = 20
Label1(0).AutoSize = ture
Label1(0).BackStyle = 0
Label1(0).FontItalic = True
Label1(0).FontBold = True
Label1(0).FontSize = 10
Label1(0).ForeColor = &HFF&
Label1(0).Caption = 0
Label1(0).Left = 1.2
Label1(0).Top = 0.5
Label1(0).Visible = True
For i = 1 To 25
Load Label1(i) '用数组的方法动态添加控件(横坐标示数)
Label1(i).Width = 40
Label1(i).Height = 20
Label1(i).AutoSize = ture
Label1(i).BackStyle = 0
Label1(i).FontItalic = True
Label1(i).FontBold = True
Label1(i).FontSize = 10
Label1(i).ForeColor = &HFF&
Label1(i).Caption = i * 60
Label1(i).Left = 1.5 + i * 2
Label1(i).Top = 0.2
Label1(i).Visible = True
'动态添加控件(横坐标上的间隔线)
Set newobj = Me.Controls.Add("vb.line", "Line" & i)
With newobj
.BorderStyle = 3
.X1 = 2 * i + 2
.X2 = 2 * i + 2
.Y1 = 2
.Y2 = 42
End With
newobj.Visible = True
Next i
For i = 41 To 60
Load Label1(i)
Label1(i).Width = 40
Label1(i).Height = 20
Label1(i).AutoSize = ture
Label1(i).BackStyle = 0
Label1(i).FontItalic = True
Label1(i).FontBold = True
Label1(i).FontSize = 10
Label1(i).ForeColor = &HFF&
Label1(i).Caption = (i + 480) * (-1)
Label1(i).Left = 0.2
Label1(i).Top = 1.4 + 2 * (i - 40)
Label1(i).Visible = True
Set newobj = Me.Controls.Add("vb.line", "Line" & i)
With newobj
.X1 = 2
.X2 = 48
.Y1 = 2 * (i - 40)
.Y2 = 2 * (i - 40)
.BorderStyle = 3
End With
newobj.Visible = True
Next i
End Sub
4、运行
温馨提示:答案为网友推荐,仅供参考