VB中报错:byref argument type mismatch什么问题啊!
源程序PrivateSubCommand1_Click()DimchxAsString*1DimnumAsIntegerchx="*"num=8Calltriangle(...
源程序
Private Sub Command1_Click()
Dim chx As String * 1
Dim num As Integer
chx = "*"
num = 8
Call triangle(chx, num)
chx = "$"
triangle chx, num / 2
End Sub
Private Sub triangle(str As Integer, n As Integer)
Dim I As Integer, J As Integer
For I = 1 To n
For J = 1 To I
Print str;
Next J
Print
Next I
End Sub
不知道为什么报错 啊!
帮手一下怎样改啊!谢了 展开
Private Sub Command1_Click()
Dim chx As String * 1
Dim num As Integer
chx = "*"
num = 8
Call triangle(chx, num)
chx = "$"
triangle chx, num / 2
End Sub
Private Sub triangle(str As Integer, n As Integer)
Dim I As Integer, J As Integer
For I = 1 To n
For J = 1 To I
Print str;
Next J
Next I
End Sub
不知道为什么报错 啊!
帮手一下怎样改啊!谢了 展开
2个回答
展开全部
在你的Private Sub triangle(str As Integer, n As Integer) 方法中,参数str 是Integer类型。而你调用的时候:Call triangle(chx, num) 中的chx是String 类型当然不匹配了。
你把Private Sub triangle(str As Integer, n As Integer)改成
Private Sub triangle(str As String , n As Integer)就可以了
你把Private Sub triangle(str As Integer, n As Integer)改成
Private Sub triangle(str As String , n As Integer)就可以了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询