VB中的CLog 是什么东东?编译是弹出:程序或子函数未定义
在编译的时候弹出:程序或子函数未定义 ,一看是(CLog((Vmin) 这个地方出错了,CLog 是什么函数?怎么样解决这个问题?
Dim x1 As Integer '定义每段线段左端点坐标
Dim yl As Integer
Dim x2 As Integer ' 定义每段线段右端点坐标
Dim y2 As Integer
'cx,cy为矩形绘图区坐标原点;
'k ,Is为矩形绘图区宽、高;kx,ky为坐标系网格线数量;
'Np曲线为屏欲显示的总点数;Vn为实时数据变量,本例中为实时速度值;
'Timer1.Interval为图形刷新间隔.
'本例中cx=62,cy=260;k =400,Is=200(坐标单位为像素);kx=5,ky=5;Timer1.Interval=50ms;Np=400.
'每次绘图前只需给以上变量赋值便可更改图形模样,也可在绘图过程中随时通过Com-boBox和CommandButton控件实时改变.
Private Sub Form_Load()
Me.Scale (-1, 10)-(25, -1) '定义坐标系,原点靠近左下角
With Form1.Picture1
Line (-1, 0)-(25, 0) '画x轴
Line (0, -1)-(0, 10) '画Y轴
For i = -1 To 25 Step 1 '画X轴刻度
If i <> 0 Then
Line (i, 0)-(i, 0.2)
CurrentX = i - 0.3: CurrentY = -0.2
Print i
End If
Next
For j = -1 To 10 '画Y轴刻度
If j <> 0 Then
Line (0, j)-(0.3, j)
CurrentX = -0.7: CurrentY = j + 0.1
Print j
End If
Next
CurrentX = -0.4: CurrentY = -0.2
Print "0" '画原点
CurrentX = 0.5: CurrentY = 9.5
Print "Y"
CurrentX = 24: CurrentY = 0.5
Print "X"
Randomize
CurrentX = 1: CurrentY = Format(Rnd * 10, "0.00")
For i = 2 To 24
Line -(i, Format(Rnd * 10, "0.00")) '这里是随机生成的数据!
Next
End With
End Sub
Private Sub Picture1_Click()
Picture1.DrawStyle = 0 '选择输出的线型的样式,以下程序略
Picture1.DrawWidth = 1 '选择输出的线型的宽度,以下程序略
End Sub
Private Sub Timer1_Timer()
Static num As Long '定义当前点的编号,在此例中同Timer中断次数
Static Np As Integer '定义实时曲线点数的记录值
Static V(1 To 2000) As Currency ' 绘图数据数组,大小及维数根据需要调整
Static sig As Boolean ' 实时曲线数据范围变化标志
Static z As Integer ' 实时曲线数据变化范围10^z
Static ymax As Currency ' 纵坐标刻度极大值
Static ymin As Currency ' 纵坐标刻度极小值
If num <= Np And num > 1 Then
x1 = cx + (num - 1) * (Ix / Np)
x2 = cx + num * (Ix / Np)
yl = cy - iy * (V(num - 1) - ymin) / (ymax - ymin)
y2 = cy - iy * (V(num) - ymin) / (ymax - ymin)
Picture1.Line (x1, y1)-(x2, y2), QBColor(1) '绘制当前实时线段
End If
If num > Np Then
Picture1.Line (cx - 35, cy + 20)-(cx + 35 + Ix, cy + 21), QBColor(8) '消隐上一次横坐标数值
For i = 1 To kx
Picture1.CurrentX = cx + (i * Ix / kx - (num Mod (Np / kx)) / Np * Ix)
Picture1.CurrentY = cy + 18
Picture1.Print Format((i * Np / kx + num - (num Mod (Np / kx)) - Np)) * Timer1.Interval / 1000, " ##,##0.00" '绘制当前横坐标刻度值
Next i
For i = 1 To kx
Picture1.Line (cx + (i * Ix / kx - ((num - 1) Mod (Np / kx)) / Np * Ix), cy)-(cx + (i * Ix / kx - ((num - 1) Mod (Np / kx)) / Np * Ix), cy - iy)
QBColor (15) ' 消隐上一次横坐标网格线
Next
For i = 1 To kx
Picture1.Line (cx + (i * Ix / kx - (num Mod (Np / kx)) / Np * Ix), cy)-(cx + (i * Ix / kx - (num Mod (Np / kx)) / Np * Ix), cy - iy)
QBColor (0) ' 绘制当前横坐标网格线
Next i
For i = 0 To ky
Picture1.Line (cx, cy - i * (kx / ky))-(cx + Ix, cy - i * (iy / ky))
QBColor (0) ' 绘制纵坐标网格线
Next i
If num > 2000 Then
x = 2000
Else
x = num ' 确定数组中当前实时数据的位置
End If
For i = 2 To Np
x1 = cx + (i - 1) * (Ix / Np)
x2 = cx + (i) * (Ix / Np)
yl = cy - iy(V(x - Np + i - 2) - ymin) / (ymax - ymin)
y2 = cy - iy(V(x - Np + i - 1) - ymin) / (ymax - ymin)
Picture1.Line (x1, y1)-(x2, y2)
QBColor (15) '消隐上一条实时曲线
Next i
If sig = True Then
Picture1.Line (cx - 35, cy + 10)-(cx - 35, cy - iy), QBColor(8) ' 消隐纵坐标刻度值
z = Log(Vmax - Vmin) / Log(10#) '计算极值范围指数
ymax = (CLog((Vmax) / (10 ^ z) + 0.5)) * (10 ^ z) '计算纵轴坐标极大
ymin = (CLog((Vmin) / (10 ^ z) - 0.5)) * (10 ^ z) '计算纵轴坐标极小值For i = 0 To ky
Picture1.CurrentX = cx - 60
Picture1.CourrentY = cy - i * iy / ky - 5
Picture1.Print Format((i * (ymax - ymin) / ky + ymln), " ##,##0.00 ") '重绘纵坐标刻度值
Next
End If
sig = False '标志位置0’
For i = 2 To Np
xl = (i - 1) * (Ix / Np)
x2 = i * (Ix / Np)
yl = cy - iy * (V(x - Np + i - 1) - ymin) / (ymax - ymin)
y2 = cy - iy * (V(x - Np + i) - ymin) / (ymax - ymin)
Picture1.Line (xl, y1)-(x2, y2), QBColor(1)
Next i
End If
End Sub
[解决办法]
没有CLog这个东东,写错了吧。应该是:CLng,强制转换成Long型。
[解决办法]
CLng,强制转换成Long型
[解决办法]
应该是CLng ,将数据转换为Long类型