Centar za edukaciju-BiH


Stranice (1):1

#1 26.09.2015 13:07
Avko Van mreze
Administrator
Registrovan od:28.05.2014
Postovi:4,691


Predmet:VB6 read write binary file error 13 type mismatch
znate li mozda gdje je problem u ovom primjeru
program se zaustavi u ovoj liniji
bytes(num_values) = values(i)
primjer je zakacen, a ako netko nema instaliran vb6 evo kod:
PreuzmiIzvorni kôd (Visual Basic):
  1. Option Explicit
  2.  
  3. Private Sub cmdWriteValues_Click()
  4. Dim file_name As String
  5. Dim file_length As Long
  6. Dim fnum As Integer
  7. Dim bytes() As Byte
  8. Dim txt As String
  9. Dim i As Integer
  10. Dim values As Variant
  11. Dim num_values As Integer
  12.  
  13.     ' Build the values array.
  14.    values = Split(txtValues.Text, vbCrLf)
  15.     For i = 0 To UBound(values)
  16.         If Len(Trim$(values(i))) > 0 Then
  17.             num_values = num_values + 1
  18.             ReDim Preserve bytes(1 To num_values)
  19.             bytes(num_values) = values(i)
  20.         End If
  21.     Next i
  22.  
  23.     ' Delete any existing file.
  24.    file_name = filePath
  25.     On Error Resume Next
  26.     Kill file_name
  27.     On Error GoTo 0
  28.  
  29.     ' Save the file.
  30.    fnum = FreeFile
  31.     Open file_name For Binary As #fnum
  32.     Put #fnum, 1, bytes
  33.     Close fnum
  34.  
  35.     ' Clear the results.
  36.    txtValues.Text = ""
  37. End Sub
  38.  
  39.  
  40. Private Sub cmdReadValues_Click()
  41. Dim file_name As String
  42. Dim file_length As Long
  43. Dim fnum As Integer
  44. Dim bytes() As Byte
  45. Dim txt As String
  46. Dim i As Integer
  47.  
  48.     file_name = filePath
  49.     file_length = FileLen(file_name)
  50.  
  51.     fnum = FreeFile
  52.     ReDim bytes(1 To file_length)
  53.  
  54.     Open file_name For Binary As #fnum
  55.     Get #fnum, 1, bytes
  56.     Close fnum
  57.  
  58.     ' Display the results.
  59.    For i = 1 To file_length
  60.         txt = txt & Format$(bytes(i)) & vbCrLf
  61.     Next i
  62.     txtValues.Text = txt
  63. End Sub
  64. Function filePath()
  65.     filePath = App.Path & "/data.hex"
  66. End Function
  67.  
  68. Private Sub Command1_Click()
  69.     End
  70. End Sub


Prilozi:
Informacije o tipu datoteke za:rar  napravi bin file proba.rar
Preuzimanja:355
Velicina datoteke:2.28 KB


zivot je moja domovina.
Ovaj post je ureden 1 puta. Posljednja izmjena 26.09.2015 13:09 od strane Avko. ↑  ↓

#2 26.09.2015 13:21
Gjoreski Van mreze
Administrator
Registrovan od:02.02.2009
Postovi:1,828


Predmet:Re: VB6 read write binary file error 13 type mismatch
Oces da upises tekst a promenliva si definirao kao Byte i normalno dobijas greski.
promeni Dim bytes() As Byte vo Dim bytes() As Variant ili Dim bytes() As String
↑  ↓

#3 26.09.2015 13:31
Avko Van mreze
Administrator
Registrovan od:28.05.2014
Postovi:4,691


Predmet:Re: VB6 read write binary file error 13 type mismatch
uuuu, ovo je bio vrlo brz odgovor. Svaka cast.
sada radi. Zahvaljujem.
zivot je moja domovina.
↑  ↓

Stranice (1):1


Sva vremena su GMT +01:00. Trenutno vrijeme: 4: 32 am.