I want to output this data to text and binary files. The binary
file contains the garbage you would expect to see if you try to
read it with a text editor, but below that the output appears as
text as it also appears in the text file. 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
lncount = 0
numbers = ""
range = Val(txtRange.Text)
stepval = Val(txtStep.Text)
modulus = Val(txtModulus.Text)
'send data to a text file and a binary file
Open "C:\windows\desktop\data\random.txt" For Output As #1
Open "C:\windows\desktop\data\rnd.dat" 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.Point(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