home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmLongDissector
- Caption = "Long Dissector"
- ClientHeight = 1800
- ClientLeft = 3960
- ClientTop = 3570
- ClientWidth = 5385
- Height = 2205
- Left = 3900
- LinkTopic = "Form1"
- ScaleHeight = 1800
- ScaleWidth = 5385
- Top = 3225
- Width = 5505
- Begin VB.TextBox txtLong
- Height = 375
- Left = 240
- TabIndex = 5
- Top = 420
- Width = 1695
- End
- Begin VB.CommandButton cmdFigureIt
- Caption = "Figure It"
- Default = -1 'True
- Height = 375
- Left = 240
- TabIndex = 0
- Top = 960
- Width = 1695
- End
- Begin VB.Label Label9
- Caption = "Byte 4:"
- Height = 195
- Left = 2700
- TabIndex = 10
- Top = 1260
- Width = 555
- End
- Begin VB.Label Label8
- Caption = "Byte 3:"
- Height = 195
- Left = 2700
- TabIndex = 9
- Top = 900
- Width = 555
- End
- Begin VB.Label Label7
- Caption = "Byte 2:"
- Height = 195
- Left = 2700
- TabIndex = 8
- Top = 540
- Width = 555
- End
- Begin VB.Label Label6
- Caption = "Byte 1:"
- Height = 195
- Left = 2700
- TabIndex = 7
- Top = 180
- Width = 555
- End
- Begin VB.Label Label5
- Caption = "Enter a long:"
- Height = 195
- Left = 240
- TabIndex = 6
- Top = 180
- Width = 1395
- End
- Begin VB.Label lblByte4
- Height = 255
- Left = 3360
- TabIndex = 4
- Top = 1260
- Width = 1335
- End
- Begin VB.Label lblByte3
- Height = 255
- Left = 3360
- TabIndex = 3
- Top = 900
- Width = 1335
- End
- Begin VB.Label lblByte2
- Height = 255
- Left = 3360
- TabIndex = 2
- Top = 540
- Width = 1335
- End
- Begin VB.Label lblByte1
- Height = 255
- Left = 3360
- TabIndex = 1
- Top = 180
- Width = 1335
- End
- Attribute VB_Name = "frmLongDissector"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Public Function ByteFromLong(LongVal As Long, Position As Integer) As Integer
- Dim iTemp As Long
- If Position < 1 Or Position > 4 Then
- ByteFromLong = -1
- Exit Function
- End If
- Select Case Position
- Case 1
- iTemp = LongVal And 127 ' Binary 01111111
- Case 2
- iTemp = LongVal And 32512 ' Binary 01111111 00000000
- iTemp = iTemp / 256 ' Binary 1 00000000
- Case 3
- iTemp = LongVal And 8323072 ' Binary 01111111 00000000 00000000
- iTemp = iTemp / 65536 ' Binary 1 00000000 00000000
- Case 4
- iTemp = LongVal And 2130706432 ' Binary 01111111 00000000 00000000 00000000
- iTemp = iTemp / 16777216 ' Binary 1 00000000 00000000 00000000
- End Select
- ByteFromLong = iTemp
- End Function
- Private Sub Command1_Click()
- End Sub
- Private Sub cmdFigureIt_Click()
- Dim iLong As Long
- iLong = Val(txtLong.TEXT)
- lblByte1.Caption = Str(ByteFromLong(iLong, 1))
- lblByte2.Caption = Str(ByteFromLong(iLong, 2))
- lblByte3.Caption = Str(ByteFromLong(iLong, 3))
- lblByte4.Caption = Str(ByteFromLong(iLong, 4))
- End Sub
-