Ver Mensaje Individual
  #5 (permalink)  
Antiguo 11/01/2010, 08:36
Avatar de pkj
pkj
 
Fecha de Ingreso: julio-2006
Ubicación: Órbita sincrónica
Mensajes: 899
Antigüedad: 17 años, 9 meses
Puntos: 29
Respuesta: leer archivo hexadecimal en VB6

Aquí te dejo un ejemplo. Para probarlo crea un form con 3 textbox y 1 commandbutton.

Se leerá un fichero hexadecimal "C:\hexa.hex"

En el Text1 se carga el texto en hexadecimal
En el Text2 se carga en decimal
En el Text3 se carga en ascii

Código vb:
Ver original
  1. Private Sub Command1_Click()
  2.   Dim NumFichero As Integer
  3.   Dim NombreArchivo As String
  4.   Dim Linea As String
  5.   Dim F As Long
  6.   NombreArchivo = "C:\hexa.hex"
  7.   NumFichero = FreeFile
  8.   Open NombreArchivo For Input As #NumFichero
  9.   Text1.Text = ""
  10.   Text2.Text = ""
  11.   Text3.Text = ""
  12.   Do Until EOF(NumFichero)
  13.     Line Input #NumFichero, Linea
  14.     Text1.Text = Text1.Text & Linea & vbCrLf
  15.     For F = 1 To Len(Linea) Step 2
  16.       Text2.Text = Text2.Text & CDec("&H" & Mid$(Linea, F, 2))
  17.       Text3.Text = Text3.Text & Chr$("&H" & Mid$(Linea, F, 2))
  18.     Next F
  19.   Loop
  20.   Close NumFichero
  21. End Sub

Saludos
__________________
No hay preguntas tontas, solo gente estup..., ¡No!, ¿como era? No hay gente que pregunte a tontos... ¡Nooo!... ¡Vaya cabeza!