在VB6中实现队列 尺寸n,前,后为整数 作为整数的Dim x Dim arr()为整数 公共函数init() n=输入框(“输入大小:”) ReDim arr(n)为整数 正面=0 后=-1 端函数 公共函数插入(x为整数) 如果后部=n-1,则 MsgBox“队列已满!!!”,vbOKOnly,“队列” 其他的 后=后+1 arr(后)=x MsgBox x,仅vbOKOnly,“插入” 如果结束 端函数 公共函数delete()为整数 如果后+1=前,则 MsgBox“队列为空!!!”,vbOKOnly,“队列” 其他的 x=arr(前) 前=前+1 返回x 如果结束 端函数 专用子插件单击() 如果后部

在VB6中实现队列 尺寸n,前,后为整数 作为整数的Dim x Dim arr()为整数 公共函数init() n=输入框(“输入大小:”) ReDim arr(n)为整数 正面=0 后=-1 端函数 公共函数插入(x为整数) 如果后部=n-1,则 MsgBox“队列已满!!!”,vbOKOnly,“队列” 其他的 后=后+1 arr(后)=x MsgBox x,仅vbOKOnly,“插入” 如果结束 端函数 公共函数delete()为整数 如果后+1=前,则 MsgBox“队列为空!!!”,vbOKOnly,“队列” 其他的 x=arr(前) 前=前+1 返回x 如果结束 端函数 专用子插件单击() 如果后部,vb6,queue,Vb6,Queue,这是我在VB6中的代码。 我在Return x行中的insert函数中发现一个错误,该行显示“预期编译器错误:语句结束” 还有一个错误是,每当我尝试删除队列的元素时,它都会显示“0已删除”您试图使用return语句从函数返回值,这在VB6中无效。在VB6中,通过将返回值指定给函数名来返回函数值 因此,对于delete函数,您可以编写以下代码: Dim n, front, rear As Integer Dim x As Integer Dim arr() As Integer Public F

这是我在VB6中的代码。 我在
Return x
行中的
insert
函数中发现一个错误,该行显示“预期编译器错误:语句结束”


还有一个错误是,每当我尝试删除队列的元素时,它都会显示“0已删除”

您试图使用return语句从函数返回值,这在VB6中无效。在VB6中,通过将返回值指定给函数名来返回函数值

因此,对于
delete
函数,您可以编写以下代码:

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
Public函数delete()为整数
如果后+1=前,则
MsgBox“队列为空!!!”,vbOKOnly,“队列”
其他的
x=arr(前)
前=前+1

delete=x'试图使用return语句从函数返回值,该语句在VB6中无效。在VB6中,通过将返回值指定给函数名来返回函数值

因此,对于
delete
函数,您可以编写以下代码:

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
Public函数delete()为整数
如果后+1=前,则
MsgBox“队列为空!!!”,vbOKOnly,“队列”
其他的
x=arr(前)
前=前+1

delete=x'什么是VB2006?VB.NET不是VB6,因此您的标记只会进一步混淆问题。如果有任何问题,如果您指的是VB6,请说VB98。请缩进您的代码。哦,您的
Dim n,front,rear As Integer
创建了两个变量和一个整数。你不能这样简化声明。什么是VB2006?VB.NET不是VB6,因此您的标记只会进一步混淆问题。如果有任何问题,如果您指的是VB6,请说VB98。请缩进您的代码。哦,您的
Dim n,front,rear As Integer
创建了两个变量和一个整数。你不能这样简化声明。