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):Option Explicit
Private Sub cmdWriteValues_Click()
Dim file_name As String
Dim file_length As Long
Dim fnum As Integer
Dim bytes() As Byte
Dim txt As String
Dim i As Integer
Dim values As Variant
Dim num_values As Integer
' Build the values array.
values = Split(txtValues.Text, vbCrLf)
For i = 0 To UBound(values)
If Len(Trim$(values(i))) > 0 Then
num_values = num_values + 1
ReDim Preserve bytes(1 To num_values)
bytes(num_values) = values(i)
End If
Next i
' Delete any existing file.
file_name = filePath
On Error Resume Next
Kill file_name
On Error GoTo 0
' Save the file.
fnum = FreeFile
Open file_name For Binary As #fnum
Put #fnum, 1, bytes
Close fnum
' Clear the results.
txtValues.Text = ""
End Sub
Private Sub cmdReadValues_Click()
Dim file_name As String
Dim file_length As Long
Dim fnum As Integer
Dim bytes() As Byte
Dim txt As String
Dim i As Integer
file_name = filePath
file_length = FileLen(file_name)
fnum = FreeFile
ReDim bytes(1 To file_length)
Open file_name For Binary As #fnum
Get #fnum, 1, bytes
Close fnum
' Display the results.
For i = 1 To file_length
txt = txt & Format$(bytes(i)) & vbCrLf
Next i
txtValues.Text = txt
End Sub
Function filePath()
filePath = App.Path & "/data.hex"
End Function
Private Sub Command1_Click()
End
End Sub
Prilozi:
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.