Bosna i Hercegovina



#1 26.09.2015-13:07
Avko Offline
Administrator
Registrovan/a od: 28.05.2014-09:21
Komentari: 2,857


Subject: 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:
DownloadIzvorni kod (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 fajlu: rar  napravi bin file proba.rar
Preuzimanja: 55
Veličina: 2.28 KB


Svatko je nekad prebolio neku gadnu bolest ili se poševio s nekim s kim nije trebao.
Ovaj komentar je mijenjan 1 puta. zadnja izmjena 26.09.2015-13:09 od strane Avko. ↑  ↓

#2 26.09.2015-13:21
Gjoreski Offline
Super Moderator
Registrovan/a od: 02.02.2009-22:24
Komentari: 1,369


Ocjena: Ocjena:100 Subject: 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 Offline
Administrator
Registrovan/a od: 28.05.2014-09:21
Komentari: 2,857


Subject: Re: VB6 read write binary file error 13 type mismatch
uuuu, ovo je bio vrlo brz odgovor. Svaka cast.
sada radi. Zahvaljujem.
Svatko je nekad prebolio neku gadnu bolest ili se poševio s nekim s kim nije trebao.
↑  ↓

Stranice (1): 1


All times are GMT +01:00. Current time: 21.01.2018-13:26.