0
 Public Function insert(x As Integer)
    If front = 0& & rear = n - 1 Or rear + 1 = front Then
     MsgBox "queue FULL !!!", vbOKOnly, "QUEUE"
    ElseIf front = -1 Then
     front = rear = 0
    ElseIf rear = n - 1 Then
     rear = 0
    Else
     rear = rear + 1
    End If
    arr(rear) = x
    MsgBox x, vbOKOnly, "INSERTED"
    List1.AddItem x
End Function

这是循环队列的 insert() 。我在“如果前 = 0& & 后 = n - 1 或后 + 1 = 前然后”
错误是“运行时错误'13'类型不匹配”。

4

2 回答 2

1

我想你的意思是

If front = 0& & rear = n - 1 Or rear + 1 = front Then

成为

 If front = 0 And rear = n - 1 Or rear + 1 = front Then

你可能真的是说

If (front = 0 And rear = n - 1) Or rear + 1 = front Then

你把你的“x”和“n”混在一起了吗

于 2012-05-11T16:02:34.443 回答
0

This is also wrong

front = rear = 0 

Should be

front = 0 
rear = 0 

= has two meanings in VB6

  • = is the equality operator, same as == in a c-like language
  • = is also the assignment statement, like the = operator in a c-like language
于 2012-05-12T08:00:16.307 回答