- Sub ReadTextDrawCircle()
- '数据文件位置
- Dim File As String
- File = "d:/program/vba/data.txt"
- Dim txtLine As String
- Dim Center(2) As Double
- Dim Radius As Double
- Open File For Input As #1
- Line Input #1, txtLine ' 读第一行标题行。
- Do While Not EOF(1) ' 循环至文件尾。
- Line Input #1, txtLine ' 读入一行数据并将其赋予某变量。
- Center(0) = Val(Left(txtLine, 20)) '圆心的X坐标
- Center(1) = Val(Mid(txtLine, 21, 20)) '圆心的Y坐标
- Radius = Val(Right(txtLine, 20)) '半径
- ThisDrawing.ModelSpace.AddCircle Center, Radius '画圆
- Loop
- Close #1
- ZoomExtents '缩放到全图
- End Sub
|