I want to output this data to text and binary files. The binary
file contains the garbage I would expect to see if I try to read
it with a text editor, but below that the output appears as text.
It's been a long time since I've written any VB code. What am I
doing wrong? (The default value of modulus is 255.)
Private Sub cmdStart_Click( )
'samples an image at intervals depending on the settings
'of range (number of rows and columns) and stepval (interval
'between pixels) and generates a prnd number by performing
'modular division on the color value of the pixel
Dim nbin As Byte
Dim numbers As String
Dim row As Integer
Dim col As Integer
Dim n As Integer
Dim colcount As Integer
Dim range As Integer
Dim stepval As Integer
Dim modulus As Integer
colcount = 0
numbers = ""
range = Val(txtRange.Te xt)
stepval = Val(txtStep.Tex t)
modulus = Val(txtModulus. Text)
'send data to a text file and a binary file
Open "C:\windows\des ktop\data\otpad .txt" For Output As #1
Open "C:\windows\des ktop\data\rnd.d at" For Binary Access Write As #2
For row = 100 To range Step stepval
For col = 100 To range Step stepval
n = pboxImage.Point (row, col) Mod modulus
nbin = pboxImage.Point (row, col) Mod modulus
numbers = numbers & Str(pboxImage.P oint(row, col)) & vbCrLf
If n > 0 Then
Print #1, n;
Put #2, , nbin
colcount = colcount + 1
If colcount Mod 10 = 0 Then Print #1, vbCrLf
End If
Next col
Next row
Close #1
Close #2
txtNumbers.Text = numbers
End Sub
file contains the garbage I would expect to see if I try to read
it with a text editor, but below that the output appears as text.
It's been a long time since I've written any VB code. What am I
doing wrong? (The default value of modulus is 255.)
Private Sub cmdStart_Click( )
'samples an image at intervals depending on the settings
'of range (number of rows and columns) and stepval (interval
'between pixels) and generates a prnd number by performing
'modular division on the color value of the pixel
Dim nbin As Byte
Dim numbers As String
Dim row As Integer
Dim col As Integer
Dim n As Integer
Dim colcount As Integer
Dim range As Integer
Dim stepval As Integer
Dim modulus As Integer
colcount = 0
numbers = ""
range = Val(txtRange.Te xt)
stepval = Val(txtStep.Tex t)
modulus = Val(txtModulus. Text)
'send data to a text file and a binary file
Open "C:\windows\des ktop\data\otpad .txt" For Output As #1
Open "C:\windows\des ktop\data\rnd.d at" For Binary Access Write As #2
For row = 100 To range Step stepval
For col = 100 To range Step stepval
n = pboxImage.Point (row, col) Mod modulus
nbin = pboxImage.Point (row, col) Mod modulus
numbers = numbers & Str(pboxImage.P oint(row, col)) & vbCrLf
If n > 0 Then
Print #1, n;
Put #2, , nbin
colcount = colcount + 1
If colcount Mod 10 = 0 Then Print #1, vbCrLf
End If
Next col
Next row
Close #1
Close #2
txtNumbers.Text = numbers
End Sub
Comment