Reputation: 931
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
This is insert() of a circular queue . I am getting an error in "If front = 0& & rear = n - 1 Or rear + 1 = front Then"
error is"Runtime error '13' type mismatch".
Upvotes: 0
Views: 881
Reputation: 30408
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 languageUpvotes: 0
Reputation: 9389
I think you meant
If front = 0& & rear = n - 1 Or rear + 1 = front Then
to be
If front = 0 And rear = n - 1 Or rear + 1 = front Then
and you probably really meant
If (front = 0 And rear = n - 1) Or rear + 1 = front Then
and are you mixing your "x" and "n"
Upvotes: 1