Reading a Text File in Visual Basic 6
hello guys, it's me again.
I am looking to have a text file to be read by doing a shell action, after the file has been made in text chars. I need it to look something like this:
Code:
With Main.CustomDialog1
.Action = 1
Main.Text1.Text = .Data
.Filter = "zip"
End With
Can someone please help me with my coding problem of mine, thanks in advance also, even....
PS: Please note that .Action = 1, is the loud open dialog box and then .Action = 2, is the quite file opening form class in my ActiveX control
Re: Reading a Text File in Visual Basic 6
reading a text file is so basic Im not sure I understand if this is really what you need.
and there should be hundreds of examples in the forum and if you google to read a text file. its not a problem you should ask for since its really documented and explained plenty!
Re: Reading a Text File in Visual Basic 6
Quote:
Originally Posted by
ThEiMp
I am looking to have a text file to be read by doing a shell action, after the file has been made in text chars
What does this mean?
Re: Reading a Text File in Visual Basic 6
-- This is what I have been working on for the graveyard and also the widow maker shifts, so then...
Code:
With Main.CustomDialog1
.Data = Item1
Open .Path & "\" & .FileName & ".zip" For Input As #1
Do While Not EOF(1)
Item1 = Input(1, #1)
Loop
Close #1
End With
Re: Reading a Text File in Visual Basic 6
I am trying to run the file into notepad using the shell command
Re: Reading a Text File in Visual Basic 6
you mean, you want to OPEN THE FILE USING NOTEPAD CALLED FROM VB6?
Re: Reading a Text File in Visual Basic 6
So, you have text files with .zip extensions?
Normally a .zip file would be a compressed file, and you can't open a compressed file for Input in Visual Basic and read anything meaningful from it.
Re: Reading a Text File in Visual Basic 6
well actually I wrote a zip data file, that I made in WinRAR and then encrypted it using VB6. Then I need to either use Input or Binary to do this with, what I am looking here to do so, with it
Re: Reading a Text File in Visual Basic 6
Quote:
Originally Posted by
SamOscarBrown
you mean, you want to OPEN THE FILE USING NOTEPAD CALLED FROM VB6?
Correct
Re: Reading a Text File in Visual Basic 6
It now looks something like this source code, as below in the code tags...
Code:
Dim Item1 As String
With Main.CustomDialog1
Open .Path & "\" & .FileName For Binary As #1
ReDim Item1(LOF(1) - 1)
Get 1, 1, Item1
Close #1
End With
Re: Reading a Text File in Visual Basic 6
What does that code have to do with opening a file using notepad? I'm confused (see my signature)....
Re: Reading a Text File in Visual Basic 6
Quote:
Originally Posted by
SamOscarBrown
What does that code have to do with opening a file using notepad? I'm confused (see my signature)....
I need to prepare the department slot for the data to then be readable. because I have encrypted it, then needs to then be unencrypted, and then made to be shelled, in the IDE...
Like this:
Code:
Rem This is the dimmed variable, that I wish to remove and use as a textbox to capture the information, to make the data text file, be done with...
Dim Item1 As String
Rem The constructing of the file goes here!!
With Main.CustomDialog1
Open .Path & "\" & .FileName For Binary As #1
ReDim Item1(LOF(1) - 1)
Get 1, 1, Item1
Close #1
End With
Rem The execution of the file goes here!!
With Main.CustomDialog1
Shell .Path & "\" & .Filename, vbMaximisedFocus
End With
Can I get this done without a Dimmed Variable, as such then please help me out here, then. it's only one variable, I wish I could do without it and still achieve my best results. could I also use a textbox to contain the data inside of it, then???
Re: Reading a Text File in Visual Basic 6
1. What is wrong with using a variable?
2. Does your code even work? Strangest way to open a file I have ever seen.
3. Once you DO open your encrypted file, you must decrypt it. If it was a zip file, you obviously have to unzip it. I surely don't see any of that being done in that 'code' of yours. For an example of encrypting and decrypting a file, see this example...maybe THAT will help you: https://www.fortypoundhead.com/showc...sp?artid=24322
Re: Reading a Text File in Visual Basic 6
An example (encryption - decryption) of one file into another.
Code:
Public Bt As Byte, Btn As Byte
Public FileLong As Long
FileLong = FileLen(FileName)
Open .Path & "\" & .FileName For Binary As #1
sFile = FreeFile
For i = 1 To FileLong
Get #1, 1, Bt 'Read 1 byte
Btn = Not (Bt) 'Byte inversion (Example of encryption and decryption)
Put #sFile, i, Btn '
Next i
Close #1
Close #sFile
Can be decrypted into a variable
Code:
Dim Item1 As String
Item1 = ""
Open .Path & "\" & .FileName For Binary As #1
For i = 1 To FileLong
Get #1, 1, Bt
Btn = Not (Bt)
Item1 = Item1 & Asc(Btn)
Next i
Close #1
Re: Reading a Text File in Visual Basic 6
ReDim on a string variable?
Re: Reading a Text File in Visual Basic 6
OP has no clue...I guess what needs to happen is OP needs to take it one step at a time:
1-learn how to decrypt a file (Maybe learn how to unzip one first????)
2-learn how to import a file
3-learn how to save a file
4-learn how to open a saved TEXT file with NotePad
Re: Reading a Text File in Visual Basic 6
Im very confused here,
most of the time ThEiMp seems to be sure about what he do.
but most of the time his examples are confusing and very oddly written.
Im amazed he can make anything work.
he forgets about FreeFile, he redim a string, he seems to want to "create" a file, but uses "Get".
I recommend reading VB6 for beginners.
https://www.freetutes.com/learn-vb6/
Re: Reading a Text File in Visual Basic 6
So sorry. I wish to open a file, using Get
Re: Reading a Text File in Visual Basic 6
the most common way, if u want to use GET is:
Code:
Dim FF%
Dim Size&
Dim Data() as Byte
FF = FreeFile
Open Filename For Binary Access Read As #FF
Size = FileLen(Filename)
ReDim Data(Size - 1)
Get #FF, , Data
Close #FF
now, Data will have the entire file into byte.
now u can convert to string, search or do whatever u want with that byte array.
Re: Reading a Text File in Visual Basic 6
You could attach a project (with appropriate comments in the code)
1 Attachment(s)
Re: Reading a Text File in Visual Basic 6
Here it is my source code with the project of mine, then so be it