vb 参数类型不符

来源:百度知道 编辑:UC知道 时间:2024/05/29 00:54:00
程序如下,求高手指点,为什么总提示与参数类型不符?
Private Sub Command1_Click()

xl = Val(Text1.Text)
xr = Val(Text2.Text)
yb = Val(Text3.Text)
yt = Val(Text4.Text)
X1 = Val(Text5.Text)
X2 = Val(Text6.Text)
Y1 = Val(Text7.Text)
Y2 = Val(Text8.Text)

Picture1.Line (xl, yb)-(xl, yt) 'xl,xr,yb,yt为裁剪多边形的四条边
Picture1.Line (xl, yt)-(xr, yt)
Picture1.Line (xr, yt)-(xr, yb)
Picture1.Line (xr, yb)-(xl, yb)
c2 = code(X2, Y2) '计算(x2,y2)的区域码*/
Do While True
c1 = code(X1, Y1) '计算(x1,y1)的区域码
If (c1 = 0) Then '(x1,y1)在窗口内
If (c2 = 0) Then '(x2,y2)在窗口内
Picture1.Line (X1, Y1)-(X2, Y2) ' 绘出直线全部可见段
Return
Else '(x2,y2)不在窗口内
t = X1: X1 = X2: X2 = t
t = Y1: Y1 = Y2: Y2 = t
t = c1: c1 = c2: c2 = t '交换(x2,y2)与(x1,y1)
End I

你必须在command1的click事件中显式地声明x as integer,y as integer,才行。也就是说,你传入的参数类型必须跟函数接收的参数类型完全一致。
在你的代码中应该是Dim X1 As Integer, Y1 As Integer
Dim X2 As Integer, Y2 As Integer