home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / projct6a / form10.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-07-10  |  11.1 KB  |  431 lines

  1. VERSION 5.00
  2. Begin VB.Form Form10 
  3.    Caption         =   "HexEdit v6.1a PD"
  4.    ClientHeight    =   8130
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   9195
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   8130
  10.    ScaleWidth      =   9195
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton Command12 
  13.       Caption         =   "APPEND"
  14.       Height          =   255
  15.       Left            =   6720
  16.       TabIndex        =   17
  17.       Top             =   7320
  18.       Width           =   2295
  19.    End
  20.    Begin VB.CommandButton Command11 
  21.       Caption         =   "SEARCH"
  22.       Height          =   255
  23.       Left            =   4560
  24.       TabIndex        =   16
  25.       Top             =   7320
  26.       Width           =   1935
  27.    End
  28.    Begin VB.CommandButton Command10 
  29.       Caption         =   "AUTHOR"
  30.       Height          =   255
  31.       Left            =   6720
  32.       TabIndex        =   15
  33.       Top             =   7680
  34.       Width           =   2295
  35.    End
  36.    Begin VB.CommandButton Command9 
  37.       Caption         =   "QUIT"
  38.       Height          =   255
  39.       Left            =   4560
  40.       TabIndex        =   14
  41.       Top             =   7680
  42.       Width           =   1935
  43.    End
  44.    Begin VB.CommandButton Command8 
  45.       Caption         =   "HEX VALUE"
  46.       Height          =   255
  47.       Left            =   6720
  48.       TabIndex        =   13
  49.       Top             =   6960
  50.       Width           =   2295
  51.    End
  52.    Begin VB.CommandButton Command7 
  53.       Caption         =   "POSITION"
  54.       Height          =   255
  55.       Left            =   4560
  56.       TabIndex        =   12
  57.       Top             =   6960
  58.       Width           =   1935
  59.    End
  60.    Begin VB.CommandButton Command6 
  61.       Caption         =   "PAGE DOWN"
  62.       Height          =   255
  63.       Left            =   6720
  64.       TabIndex        =   11
  65.       Top             =   6600
  66.       Width           =   2295
  67.    End
  68.    Begin VB.CommandButton Command5 
  69.       Caption         =   "PAGE UP"
  70.       Height          =   255
  71.       Left            =   4560
  72.       TabIndex        =   10
  73.       Top             =   6600
  74.       Width           =   1935
  75.    End
  76.    Begin VB.CommandButton Command4 
  77.       Caption         =   "LEFT"
  78.       Height          =   255
  79.       Left            =   8040
  80.       TabIndex        =   9
  81.       Top             =   6240
  82.       Width           =   975
  83.    End
  84.    Begin VB.CommandButton Command3 
  85.       Caption         =   "RIGHT"
  86.       Height          =   255
  87.       Left            =   6720
  88.       TabIndex        =   8
  89.       Top             =   6240
  90.       Width           =   975
  91.    End
  92.    Begin VB.CommandButton Command2 
  93.       Caption         =   "DOWN"
  94.       Height          =   255
  95.       Left            =   5640
  96.       TabIndex        =   7
  97.       Top             =   6240
  98.       Width           =   855
  99.    End
  100.    Begin VB.CommandButton Command1 
  101.       Caption         =   "UP"
  102.       Height          =   255
  103.       Left            =   4560
  104.       TabIndex        =   6
  105.       Top             =   6240
  106.       Width           =   735
  107.    End
  108.    Begin VB.ListBox List3 
  109.       Height          =   255
  110.       Left            =   4560
  111.       TabIndex        =   5
  112.       Top             =   5880
  113.       Width           =   4455
  114.    End
  115.    Begin VB.ListBox List2 
  116.       BeginProperty Font 
  117.          Name            =   "Terminal"
  118.          Size            =   6
  119.          Charset         =   255
  120.          Weight          =   700
  121.          Underline       =   0   'False
  122.          Italic          =   0   'False
  123.          Strikethrough   =   0   'False
  124.       EndProperty
  125.       Height          =   1860
  126.       Left            =   4560
  127.       TabIndex        =   4
  128.       Top             =   3720
  129.       Width           =   4455
  130.    End
  131.    Begin VB.ListBox List1 
  132.       Height          =   3375
  133.       Left            =   4560
  134.       TabIndex        =   3
  135.       Top             =   120
  136.       Width           =   4455
  137.    End
  138.    Begin VB.FileListBox File1 
  139.       Height          =   4185
  140.       Left            =   120
  141.       TabIndex        =   2
  142.       Top             =   3720
  143.       Width           =   4335
  144.    End
  145.    Begin VB.DirListBox Dir1 
  146.       Height          =   3015
  147.       Left            =   120
  148.       TabIndex        =   1
  149.       Top             =   480
  150.       Width           =   4335
  151.    End
  152.    Begin VB.DriveListBox Drive1 
  153.       Height          =   315
  154.       Left            =   120
  155.       TabIndex        =   0
  156.       Top             =   120
  157.       Width           =   4335
  158.    End
  159. Attribute VB_Name = "Form10"
  160. Attribute VB_GlobalNameSpace = False
  161. Attribute VB_Creatable = False
  162. Attribute VB_PredeclaredId = True
  163. Attribute VB_Exposed = False
  164. Dim cellpage As Long
  165. Dim cellposition As Long
  166. Dim fileloaded As Integer
  167. Private Sub Command1_Click()
  168. Rem move up 1 line
  169. If fileloaded Then
  170.    If cellposition - 8 - cellpage * 80 > 0 Then
  171.       cellposition = cellposition - 8
  172.       Call DisplayHex
  173.     End If
  174.    MsgBox ("No file loaded.")
  175. End If
  176. End Sub
  177. Private Sub Command10_Click()
  178. MsgBox ("This public domain program" + Chr$(13) + _
  179. "written by Erik Jon Oredson" + Chr$(13) + _
  180. "Email: azathoth@rptanet.org")
  181. End Sub
  182. Private Sub Command11_Click()
  183. Rem search for hex value
  184. Static a As String * 1
  185. Static i As String
  186. Static z As Integer
  187. Static x As Long
  188. If fileloaded Then
  189.    i = InputBox("Input hex search value")
  190.    z = Int(Val("&H" + i))
  191.    If z >= 0 And z <= 255 Then
  192.       If cellposition < LOF(1) Then
  193.          For x = cellposition + 1 To LOF(1)
  194.             Get 1, x, a
  195.             If Asc(a) = z Then
  196.                cellposition = x
  197.                cellpage = Int(x / 80)
  198.                Call DisplayHex
  199.                Exit Sub
  200.             End If
  201.           Next
  202.        End If
  203.        MsgBox ("Hex value not found.")
  204.     Else
  205.        MsgBox ("Hex value must be from 00 to FF.")
  206.     End If
  207.    MsgBox ("No file loaded.")
  208. End If
  209. End Sub
  210. Private Sub Command12_Click()
  211. Rem append to file
  212. Static a As String * 1
  213. Static i As String
  214. Static z As Integer
  215. If fileloaded Then
  216.    i = InputBox("Input hex value")
  217.    z = Int(Val("&H" + i))
  218.    If z >= 0 And z <= 255 Then
  219.       a = Chr$(z)
  220.       cellposition = LOF(1) + 1
  221.       cellpage = Int(cellposition / 80)
  222.       Put 1, cellposition, a
  223.       Call DisplayHex
  224.    Else
  225.       MsgBox ("Hex value must be from 00 to FF")
  226.    End If
  227.    MsgBox ("No file loaded.")
  228. End If
  229. End Sub
  230. Private Sub Command2_Click()
  231. Rem move down 1 line
  232. If fileloaded Then
  233.    If cellposition + 8 - cellpage * 80 <= 80 Then
  234.       If cellposition + 8 <= LOF(1) Then
  235.          cellposition = cellposition + 8
  236.          Call DisplayHex
  237.        End If
  238.     End If
  239.    MsgBox ("No file loaded.")
  240. End If
  241. End Sub
  242. Private Sub Command3_Click()
  243. Rem move right 1 cell
  244. If fileloaded Then
  245.    If cellposition + 1 - cellpage * 80 <= 80 Then
  246.       If cellposition + 1 <= LOF(1) Then
  247.          cellposition = cellposition + 1
  248.          Call DisplayHex
  249.        End If
  250.     End If
  251.    MsgBox ("No file loaded.")
  252. End If
  253. End Sub
  254. Private Sub Command4_Click()
  255. Rem move left 1 cell
  256. If fileloaded Then
  257.    If cellposition - 1 - cellpage * 80 > 0 Then
  258.       cellposition = cellposition - 1
  259.       Call DisplayHex
  260.     End If
  261.    MsgBox ("No file loaded.")
  262. End If
  263. End Sub
  264. Private Sub Command5_Click()
  265. Rem page up
  266. If fileloaded Then
  267.    If cellposition - 80 > 0 Then
  268.       cellposition = cellposition - 80
  269.       cellpage = cellpage - 1
  270.    Else
  271.       cellposition = 1
  272.       cellpage = 0
  273.    End If
  274.    Call DisplayHex
  275.    MsgBox ("No file loaded.")
  276. End If
  277. End Sub
  278. Private Sub Command6_Click()
  279. Rem page down
  280. If fileloaded Then
  281.    If cellposition + 80 <= LOF(1) Then
  282.       cellposition = cellposition + 80
  283.       cellpage = cellpage + 1
  284.       Call DisplayHex
  285.    Else
  286.       If (cellpage + 1) * 80 <= LOF(1) Then
  287.          cellposition = (cellpage + 1) * 80 + 1
  288.          cellpage = cellpage + 1
  289.          Call DisplayHex
  290.       Else
  291.          cellposition = LOF(1)
  292.          Call DisplayHex
  293.       End If
  294.    End If
  295.    MsgBox ("No file loaded.")
  296. End If
  297. End Sub
  298. Private Sub Command7_Click()
  299. Rem input position
  300. Static i As String
  301. Static z As Long
  302. If fileloaded Then
  303.    i = InputBox("Input hex position")
  304.    z = Int(Val(i))
  305.    If z > 0 And z <= LOF(1) Then
  306.       cellposition = z
  307.       cellpage = Int((z - 1) / 80)
  308.       Call DisplayHex
  309.     Else
  310.        MsgBox ("Hex position not within file.")
  311.     End If
  312.    MsgBox ("No file loaded.")
  313. End If
  314. End Sub
  315. Private Sub Command8_Click()
  316. Rem input value
  317. Static a As String * 1
  318. Static i As String
  319. Static z As Integer
  320. If fileloaded Then
  321.    i = InputBox("Input hex value")
  322.    z = Int(Val("&H" + i))
  323.    If z >= 0 And z <= 255 Then
  324.       a = Chr$(z)
  325.       Put 1, cellposition, a
  326.       Call DisplayHex
  327.    Else
  328.       MsgBox ("Hex value must be from 00 to FF")
  329.    End If
  330.    MsgBox ("No file loaded.")
  331. End If
  332. End Sub
  333. Private Sub Command9_Click()
  334.  Close
  335. End Sub
  336. Private Sub Dir1_Change()
  337.  Form10.File1.Archive = True
  338.  Form10.File1.Hidden = True
  339.  Form10.File1.ReadOnly = True
  340.  Form10.File1.System = True
  341.  Form10.File1.Path = Form10.Dir1.Path
  342. End Sub
  343. Private Sub Drive1_Change()
  344. Form10.Dir1.Path = Form10.Drive1.Drive
  345. End Sub
  346. Private Sub File1_Click()
  347.  Static r As Integer
  348.  Static z As Long
  349.  Form10.List1.Clear
  350.  x$ = Form10.Dir1.Path
  351.  If Right$(x$, 1) <> "\" Then
  352.     x$ = x$ + "\"
  353.  End If
  354.  q$ = x$
  355.  Form10.List1.AddItem "Directory:"
  356.  While Len(x$) > 50
  357.     y$ = Left$(x$, 50)
  358.     x$ = Mid$(x$, 51)
  359.     If Len(x$) Then
  360.        y$ = y$ + ".."
  361.     End If
  362.     Form10.List1.AddItem y$
  363.  Wend
  364.  If Len(x$) Then
  365.     Form10.List1.AddItem x$
  366.  End If
  367.  x$ = Form10.File1.filename
  368.  q$ = q$ + x$
  369.  Form10.List1.AddItem "Filename:"
  370.  While Len(x$) > 50
  371.     y$ = Left$(x$, 50)
  372.     x$ = Mid$(x$, 51)
  373.     If Len(x$) Then
  374.        y$ = y$ + ".."
  375.     End If
  376.     Form10.List1.AddItem y$
  377.  Wend
  378.  If Len(x$) Then
  379.     Form10.List1.AddItem x$
  380.  End If
  381.  z = FileLen(q$)
  382.  Form10.List1.AddItem "Filesize: " + Format$(z, "#,##0.0")
  383.  Form10.List1.AddItem "Attributes:"
  384.  r = GetAttr(q$)
  385.  If (r And vbArchive) Then
  386.     Form10.List1.AddItem "Archive"
  387.  End If
  388.  If (r And vbHidden) Then
  389.     Form10.List1.AddItem "Hidden"
  390.  End If
  391.  If (r And vbReadOnly) Then
  392.     Form10.List1.AddItem "Read-only"
  393.  End If
  394.  If (r And vbSystem) Then
  395.     Form10.List1.AddItem "System"
  396.  End If
  397.  Close #1
  398.  Open q$ For Binary As #1
  399.  fileloaded = True
  400.  cellpage = 0
  401.  cellposition = 1
  402.  Call DisplayHex
  403. End Sub
  404. Sub DisplayHex()
  405. Static a As String * 1
  406. Static n As Long
  407. Form10.List2.Clear
  408. n = cellpage * 80
  409. For l = 1 To 10
  410.    k$ = ""
  411.    For m = 1 To 8
  412.       n = n + 1
  413.       If n > LOF(1) Then
  414.          Exit For
  415.       End If
  416.       Get 1, n, a
  417.       If n = cellposition Then
  418.          k$ = k$ + "[" + Right$("0" + Hex$(Asc(a)), 2) + "] "
  419.       Else
  420.          k$ = k$ + " " + Right$("0" + Hex$(Asc(a)), 2) + "  "
  421.       End If
  422.    Next
  423.    Form10.List2.AddItem k$
  424.    If n > LOF(1) Then
  425.       Exit For
  426.    End If
  427. Form10.List3.Clear
  428. k$ = "Position:" + Str$(cellposition) + " Cellpage:" + Str$(cellpage)
  429. Form10.List3.AddItem k$
  430. End Sub
  431.