Okay, I have a few files for the Betabrite Messaging Sign that you see at banks and whatnot. It has code in it, which without word wrap shows all on 1 line. So it could easily be a string in VB. However, it has chr$ codes in it, so it will stop reading partway through it.
My file reading code is simple, so that may be why:
VB Code:
If Dir$(App.Path & "\out.txt") <> "" = True Then
fnum = FreeFile
Open App.Path & "\out.txt" For Input As fnum
Input #fnum, livekey
Close fnum
End If
Text1.Text = livekey
Attached are 2 examples, out.txt being the more complicated one and out2.txt being a simple test.
The question is: How do you get VB to read the entire string flawlessly? This string has to be repeated back flawlessly for the sign.
The second question: VB doesn't like handling this real well because of the chr$ in it, so how can it be parsed out in something a bit more digestable? I was thinking I could convert it to VB friendly characters then reparse to send to the sign when need be, but the question does remain of how to initally get all the info.
This is a fun one I have been fighting with for 3 days, so I say good luck and hope maybe someone out there can help with this!
Line Input would require Do...Loop if file contains multiple lines so you can read and parse each line individually.
Othere than that I agree with Static's suggestion.
That's a no-go. It's a single line, so no need to get more lines. The problem is the dreaded chr$ in there. There is a chr$13 (Return) and chr$27 (Escape). That's going to be the big problem. Need to expect terminating chr$ and how to combat that.
You know, your thread title and last explanations are very confusing, sorry.
There is a function in VB Chr$() but you refer to some character as chr$, so what is it that you need to do? Do you want to exclude everything prior to the dollar sign or after or include ??? Can you tell us (based on the sample file you provided) what do you want to get out of it.
btw, Line Input can read single line and not necessary from within the loop ...
You know, your thread title and last explanations are very confusing, sorry.
There is a function in VB Chr$() but you refer to some character as chr$, so what is it that you need to do? Do you want to exclude everything prior to the dollar sign or after or include ??? Can you tell us (based on the sample file you provided) what do you want to get out of it.
btw, Line Input can read single line and not necessary from within the loop ...
Sorry about the confusion...
In the text files attached are characters in ASCII character format (http://www.lookuptables.com/). In notepad you can see them as [] (boxes like that). Essentially they are the actual character for Enters, Escapes, etc... You can copy and paste it, but once you do then you lose some of the characters and then it freezes up the sign. So the only way to get it is from the out.txt itself. So that is the quandry right now, how in the world to get that code into VB and make it digestable.
That's pretty much what we are looking at. So when VB reads it, it wants to terminate at a carriage return or escape or something of such.
And got the error: Run-time error '458' - Variable uses an automation type not supported in Visual Basic
I think you are going somewhere good with this though, it is very interesting to try. See if you can get anywhere with the txt files I attached on the original.
That was it! Wow, that was a pain in my backside but that code worked. That made things work a whole bunch better.
Lets say I do have more than 1 of these in a TXT file (thinking towards the future), what would I do to make it read the next line or is it limited to 1 a text file?
That sample code reads entire file by chunks of 1024 bytes and "collects" it into one easy to read string variable. So, you just have to parse that text.
If number of characters on each line is fixed then set size of BLOCK_SIZE to be equal to the size of your line and process each chunk individually. I doubt however that line is fixed...
Okay, here is another one for you, similar but it is multilined now. So now instead of having just 1 line of text like this, now it has more than 1 line. Can this code be modified to read a single line at a time, instead of the whole file?
I've never seen two-line scrolling marquees. Wouldn't that be very hard to read? Unless you could only see one line at a time, like on two sides of a building.
Actually it doesn't show 2 lines at a time, but the program I am making stores different lines for it to show at different times. It will allow showing of items for customization and greetings, like changes in the time of day.
So that is why I am making a text file that has more than 1 of these lines.
Unless I'm missing something I don't really see any differences between single and multiline files - that sample I've posted should take care of it.
Also, if your program creates these files then you may try to begin each line with some character(s) that you would recognize where new line begins so it would be much easier to parse.
Say, you begin each line with [CHRIS], then use my original sample to get entire text and when you done use Split() function to actually split that text on your set of characters, create array and loop through array to parse each item (line):
VB Code:
Dim arLines() As String
Dim i%
arLines = Split(strText, "[CHRIS]")
For i = 0 To UBound(arLines)
'do something here
Next i
Last edited by RhinoBull; Nov 2nd, 2005 at 09:11 AM.