I Need Help (Probably with write to or open file)
Posted: Wed Jun 29, 2005 11:39 am
I don't why it's doing this & it's racking my brain figuring it out but here is the cod I wrote.
I want it so that when the letters AAAA count up to ZZZZ it will write into a text file & new text file every 500kb. I figure swallow my pride & ask you people.
Here is the code.
in the Open "C:\My Documents\letters.txt" For Output As #1 column when it keeps telling me there is a path error but I'm pretty sure that's the right path. If I just put the "letters.txt" & hit run a black screen comes up for an about 10 seconds then it tells me to hit continue which when I check the file it supposed to write to after, nothing in it.
I hope this wasn't to long for you people, thank you[/code]
I want it so that when the letters AAAA count up to ZZZZ it will write into a text file & new text file every 500kb. I figure swallow my pride & ask you people.
Here is the code.
Code: Select all
Declare Function Increase$ (Lett As String)
' You start off with AAAA
Dim Letters As String
Letters = "AAAA"
Open "C:\My Documents\letters.txt" For Output As #1
Do
Print #1, Letters
Letters = Increase$(Letters)
Loop Until Letters = "AAAA" 'it gets AAAA again after ZZZZ (but isn't printed)
Close
End
Function Increase$ (Lett As String)
Dim RetStr As String
Dim position As Integer, flipped As Integer
RetStr = Lett
flipped = 0
position = 1
Do
' reset flag
flipped = 0
' increase the letter at specified position
If Mid$(RetStr, position, 1) = "Z" Then
Mid$(RetStr, position, 1) = "A"
flipped = -1
position = position + 1
Else
Mid$(RetStr, position, 1) = Chr$(Asc(Mid$(RetStr, position, 1)) + 1)
End If
Loop Until Not(flipped) Or position = Len(RetStr) + 1
Increase$ = RetStr
End Function
I hope this wasn't to long for you people, thank you[/code]