0
Dim n, front, rear As Integer
Dim x As Integer
Dim arr() As Integer
Public Function init()
n = InputBox("Enter size :")
ReDim arr(n) As Integer
front = 0
rear = -1
End Function
Public Function insert(x As Integer)
If rear = n-1 Then
MsgBox "queue FULL !!!", vbOKOnly, "QUEUE"
Else
rear = rear + 1
arr(rear) = x
MsgBox x, vbOKOnly, "INSERTED"
End If
End Function
Public Function delete() As Integer
If rear + 1 = front Then
MsgBox "queue Empty !!!", vbOKOnly, "QUEUE"
Else
x = arr(front)
front = front + 1
Return x
End If
End Function
Private Sub inser_Click()
If rear < n Then
x = InputBox("Enter element :")
Call insert(x)
Else
MsgBox "queue FULL !!!", vbOKOnly, "QUEUE"
End If
End Sub
Private Sub del_Click()
x = delete()
MsgBox x, vbOKOnly, "DELETED"
End Sub
Private Sub Exit_Click()
End
End Sub
Private Sub Form_Load()
Call init
End Sub
这是我在VB6中的代码。 我在Return x
线的地方说得到一个错误insert
功能“编译错误预期:语句结束”在VB6中实现队列
还有一个错误是,每当我试图删除队列中的元素显示“0删除”
什么是VB2006? VB.NET不是VB6,所以你的标签只会让事情更加混乱。 – Oded
如果你有任何意见,如果你的意思是VB6 VB98。 – Bob77
请缩进您的代码。 [看看它更容易遵循吗?](http://stackoverflow.com/posts/10538957/revisions) – Deanna