Skip to content

Instantly share code, notes, and snippets.

@hurelhuyag
Created May 17, 2019 14:38
Show Gist options
  • Save hurelhuyag/bd82c60bb08f45bd4df07c3edd7cf028 to your computer and use it in GitHub Desktop.
Save hurelhuyag/bd82c60bb08f45bd4df07c3edd7cf028 to your computer and use it in GitHub Desktop.
VB6 useful snippets
'https://www.experts-exchange.com/questions/26294906/Calculating-LRC-using-VB-Net.html
Public Function CalcChecksum(ByVal strMessage As String) As Char
Dim byteChecksum As Byte
Dim strChar As Char
For Each strChar In strMessage
byteChecksum = byteChecksum Xor Convert.ToByte(strChar)
Next
Return Convert.ToChar(byteChecksum)
End Function
'https://stackoverflow.com/questions/10538957/implementing-a-queue-in-vb6
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment