HELP: View Text File's Content By VB
Please show me how can I view content of text file (i.e logfiles *.txt) by using VB code?
Thaks
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Displaying Text File Content In A Datagrid Then Open That Text File...
I have a form named frmTest and contains a datagrid called dgData and two buttons. One is button 'Read text file' and the other one is 'open text file'. I also have a class module named CReadFile. and a textfile named test.txt
The code for button Read text file is:
Code:
Private Sub cmdReadTXT_Click()
Dim obj As CReadFile
Set obj = New CReadFile
Set dgData.DataSource = obj.Read_Text_File
Set obj = Nothing
End Sub
and the code for the open text file button is:
Code:
Open "test.txt" For Input As 1
MsgBox "file opened."
Close
The code inside the class module is:
Code:
Option Explicit
Public Function Read_Text_File() As ADODB.Recordset
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
conn.Open "DRIVER={Microsoft Text Driver (*.txt; *.csv)};" & _
"DBQ=" & App.Path & ";", "", ""
rs.Open "select * from [test#txt]", conn, adOpenStatic, _
adLockReadOnly, adCmdText
Set Read_Text_File = rs
Set rs = Nothing
Set conn = Nothing
End Function
_____________
This is what happens, if you click the button 'Read text file', the contents of the text file will be displayed in the data grid. After clicking the button 'Read text file', I now want to click the button 'Open text file' to open the text file, but an error appears saying: Run time error '70': Permission Denied.
Why is that so? What should I do to solve this problem? I need to open that file again for validation after displaying the contents.
Thank you.
Converting The Content Of The Text File To The Original File
Hi,
Here's the situation
-Let say I have a file called "Test.zip"
-then I change the extension name to .txt to convert it to text file
-of course when you open it you'll see symbols and other unknown characters
- here's the question:
Is it possible to read that uncommon content of the text file to retain or convert it back to it's original form ( in this case to .zip file)
can someone show me how it's done?
Transfer Text File Content
Hi everyone, can someone show me a code how to transfer content of a text file to another text file?
one text file named A.text i want to open using "For Open" and another one (B.text) using "For Append"..so i want everything in A.text transfer to B.text
Modifying Content In Text File
Hi,
I have a text file "orig.txt" with the content:
0:NV0067:8:BV1:Normal:66.103.203.35
0:NV0067:9:BV2:Normal:66.103.203.36
0:NV0067:10:BV3:Normal:66.103.203.37
0:NV0067:11:BV4:Normal:66.103.203.38
0:NV0067:12:BV5:Normal:66.103.203.39
0:NV0067:13:BV6:Normal:66.103.203.40
I need help in making a vb program that will modify the content in "orig.txt" to this format and save it as modified.txt:
66.103.203.35 X-NV0067-BV1
66.103.203.36 X-NV0067-BV2
66.103.203.37 X-NV0067-BV3
66.103.203.38 X-NV0067-BV4
66.103.203.39 X-NV0067-BV5
66.103.203.40 X-NV0067-BV6
at the end, delete "orig.txt" file.
Any help would be appreciated. thanks!
Filtering Out Content From A Text File
I am using the following code to open a text file that contains URLs, I want to "filter" out only the lines/words that start with http https cookie etc and show only the relevant text
how would i modify my dode to do this?
Dim strInput As String
Private Sub Command1_Click()
Open "C: ext.dat" For Input As #1
Do Until EOF(1)
Input #1, strInput
RichTextBox1.Text = RichTextBox1.Text & strInput
Loop
Close #1
End Sub
Getting Content From Text File To Listbot
Like the title stated, I would like to know how I can save the items in a list box to a text file, then retrieve it when needed. I'm going to have names that are going to be added to the listbox and I didn't want to add the items manually everytime i ran the program. Thanks.
Copy Content Of A Text File To Another
How can i copy the content of a text file to another already existing textfile? This copy must first delete the content of the file it writes to.
i.e.
content of file1:
1234567890
content of file2:
aaaaaaaaa
result must be:
erase content of file 2 (aaaaaaaaa) and replace by content of file 1=1234567890
file2=
1234567890
Saving The Content Of A Text Box Into A File
i want to have it so when you press a button it saves whatever is in the text box to a file and then if there is a file existing when you open the program again it will load the text from the file into the text box
Edited by - Split on 12/10/2005 1:12:17 PM
Sort Text File Content. Ideas Please :D
Hi ppl.
i have a text file look like this:
Code:
t155.4 ;B277i ;t.3918 ; ; ;
t155.4 ;B277i ;t.3917 ; ; ;
t371.102019 ;M672v ;t.3945 ; ; ;
t371.102019 ;M672v ;t.3946 ; ; ;
m347.952 ;A511e ;t.19409 ; ; ;
m331.88(81) ;P436c ;t.19396 ; ; ;
m347.955 ;P436r ;t.19362 ; ; ;
m34:502.7 ;V855r ;t.19338 ; ; ;
m347.77 ;A779p ;t.19358 ; ; ;
m347.919.3 ;O48j ;t.19373 ; ; ;
and i need to sort him in ALPHABETICAL order, using 2nd column (separated by ; ) to make a sort. i have to 'transform' my text file in something exactly like this:
Code:
m347.77 ;A779p ;t.19358 ; ; ;
m347.952 ;A511e ;t.19409 ; ; ;
t155.4 ;B277i ;t.3917 ; ; ;
t155.4 ;B277i ;t.3918 ; ; ;
t371.102019 ;M672v ;t.3945 ; ; ;
t371.102019 ;M672v ;t.3946 ; ; ;
m347.919.3 ;O48j ;t.19373 ; ; ;
m331.88(81) ;P436c ;t.19396 ; ; ;
m347.955 ;P436r ;t.19362 ; ; ;
m34:502.7 ;V855r ;t.19338 ; ; ;
ps: i already open, read and works with file contents normally. i just want sort content of file using 2nd column.
anybody can help me ?
How To Save Listbox Content To A Text File
Hi,
I need to write the data in a list box to a text file by creating the text file.
whenever the list box receives a data it should save the data to the text file.
Next time when the data comes to the list box it should get appended with the existing text present in the file.
how can i do that in VB?
I am new to VB...
Expecting reply
thanks in advance
How To Put A Text File Content In A Public String???!!!!
Hi
I have a text file (nearly 3.6 MB)..
I must use it at anytime in my project (all forms..)
So I must read it to one string (public for all at any time).. not to read it every time I want it..
So how to do it with VB6??
It is an urgent problem please!!!
Thanks alot..
Reading A Text File And Overwriting The Content
greetings vb experts. i just want to ask, what's the code for opening a text file, and overwriting its content. as i remem it has commands such as,
open file #.... (and so on)
can you pls help me... thank you so much
How To Put A Text File Content In A Public String???!!!!
Hi
I have a text file (nearly 3.6 MB)..
I must use it at anytime in my project (all forms..)
So I must read it to one string (public for all at any time).. not to read it every time I want it..
So how to do it with VB6??
It is an urgent problem please!!!
Thanks alot..
Showing The Content Of Notepad File In A Text Box Control
Hi all,
Hope all in fine tune. Here I am uploading a text file. What all I need is that I want to show the content of the file in text box control of a form with multiline set to true and scroll bars to both. But the contents are coming in the control but are compressed to a new line and the alignments are going off. My requirement is to show the contents exactly in the same way as it appears in the notepad file when maximized.Please help me as a project is withheld for this code.
Help me Plzzzzzzzzzzzzzzz
Thanx in advance
How To Display The Content Of Text File In The Data Report?
Hey dude,
I want to to show the content of the text file in the data report. Can you please let me know that how can show the text file stuff in the data report.
code snippets will be prefered.
Thanks I am eagerly waiting for your reply.
please. help me.
Thanks
Kamlesh Gujarathi
kamlesh@itshastra.com
Fly always to the SKY. You can do anything if you TRY. ;)
Need To Be Able To View E-mail Content
I need to be able to view the newset e-mail message in my inboxy and get a link or some text from the message. What is the easiest way to do this. I dose not matter if its pop e-mail or web.
Reading The Content Of A Text File Via Line Input, Backwards!
I am using Line input to read the content of a txt file into a listbox. As each line is read in, a function is called upon to check for something. It would be very helpful if I could read the text file in reverse, so the first line is read last.
Is there a way to do this?
Thanks!
Opening Textfile To View Its Content
Hello friends,
I have a file in the location "c:/testtxt.txt". Now the situation is when i execute the code, i need to open the particular file in order to view its content.
Help, How Can I View This Text File
Hi, i have a text file named Phonebook.ini
And it contains data like this:
Code:
//please do not edit
[PHONEBOOK]
Aybyd=09183060000
Test1=09186030000
Test2=91824555547
[/PHONEBOOK]
How can i view or load this with my ListView?
My ListView have column header: Phone Number and Name
it goes something like this:
Name Phone Number
Aybyd 09183060000
View File In Text Box
Hi!I have a problem viewing a file code into a text box.
I can view text file...but when i try to open the source of some other files i am getting in the text box only few lines from the file's code.
i'm using this code to view:
Open adress For Input As #1
Do While Not EOF(1)
Input #1, string
Text = Text & string & Chr(13) & Chr(10)
Loop
Close #1
p.s.: how many bytes can dysplay a text box???
What can i do to view more text???
plz help
thanks!
View Text File
How can I Open a stored *.txt file for viewing using Visual Basic Code. I tried "Shell" command but did not get the result.
Please help.
Regards,
Sam
View Html Text In Browser Without File?
http://www.xtremevbtalk.com/showpost...6&postcount=33
FlyGuy posted some code entitled:
Create HTML table from MSFlexGrid control
on
http://www.xtremevbtalk.com/showpost...6&postcount=33
The code generates a html flexgrid tags n all into a string.
I would like to place this into a WebBrowser from vb6.
I can save the text as a file with a .html extention and set the browser to open the file.
Is there a way to view the .html by assigning the text to the browser without having to save the text to a file first?
Is there another control that would allow me to do this?
Reading Text File/Using Delimiters/Putting Into List View
Hey, haven't been here for several months. Main reason is I just shortly got back from Iraq. Ohh Rahh!
I'm sorry buy I might answer my own question(s) as I am tryping this out, I just have used vb for a long time so work with me people. (And point it out if I did answer my own question(s).
Ok here's my question I want to speperate a text file that has info in it that is set up like this:
Code:
Account:User1;Password:Help;Access:Restricted
Account:User2;Password:Me;Access:Restricted
Account:User3;Password:Please;Access:Restricted
Account:User4;Password:Thanks;Access:Restricted
Account:User5;Password:In;Access:Restricted
Account:User6;Password:Advance;Access:Restricted
Yes, it's been asked a 1,000 times by other people and yes I am looking around for the answer. But I seen that you (who ever is reading this) had the urge to help me out anyways.
1. I know I need to use something like this:
Code:
Dim Data(20) As String
Private Sub cmdLVFill_Click()
Dim TempCounter As Integer
Dim filenum As Integer
filenum = FreeFile
Open "C:Info.txt" For Input As #filenum
Do While Not EOF(filenum)
Input #filenum, Data(Counter)
Counter = Counter + 1
Loop
Close #filenum
Dim i As Integer
For i = 1 To Counter - 1
'Instr Stuff goes here? Then put the fields into an array.
' This is where I would put in my listview fun stuff
' Using Redim to store it all I suppose seeing how I don't know the length of the file.
'THis doesn't sound right to me but something along those lines...
Next
End Sub
2. I think I need to use Instr:
Code:
i = LineOfFIle
'as in line 1
'Account:User1;Password:Help;Access:Restricted
a = 1
Do While Not EOF(filenum)
a = InStr(i, ":")
b = Instr(a, i, ";")
Account = CStr(Mid(i, b, a - b))
c = Instr(b, i, ":")
d = InStr(c, i, ";")
Password = CStr(Mid(i, d, c - d))
'I don't know how bad or far off that is but It doesn't look right to me
Windows File Explorer.. Icon View And List View.
I'm trying to duplicate a function of the explorer.. The folder contents view.
See example of what I mean...
http://www.ibarn.net/fun/files/thumblist.jpg
I can do everything I need using the filelistbox with the sole exception of changing the display style. I don't want a file list, I want a list-view or icon-view. (Preferably both, with the option to switch between them.)
So my question to you fine people is...... what API or component could I find this capacity in? I've looked at all of the components and didn't see anything that looked close, and a search on the subject yeilds hundreds of people trying to emulate the "filemanager" explorer style, but none trying to kick out a normal, boring icon view like this.
Any help would be greatly appreciated.
Thanks.
TextBox.text Content Retreival Of A Portion Of Text
Hi all,
I am stuck at a place where i have a text of 9 char length.
I need to retrieve the middle 3 characters....
eg:-
123456789
i can retrieve the first 3 characters(123) using the
Code:left("123456789",3)command
and retrieve the last 3 using the
Code:right("123456789",3)command
but how do i get the middle 3 characters(i.e. 456) extracted??
here is what i tried.
Code:str1 = txtBackground.Text
'store contents into a variant variable
str1 = Replace(str1, Left(str1, 3), "")
'replace the first 3 chars with ""
str1 = Replace(str1, Right(str1, 3), "")
'replace the last 3 chars with ""
finalstr = str1
'the final string in above example(456)
but, result of above operation is ""
any help shall be appreciated...
Please help me fast.
Thanks in Advance.
P.S.: I DONT WANT TO USE THE MID FUNCTION
------------------------------------------------------------------------------------------------
www.Tech-Arena.com/forums
The Indian Perspective Of Technology.
Edited by - Crazycoder on 9/19/2004 3:14:39 AM
Read Line By Line Of Text File And Move Content To Excel Record By Record
Hi,
i am trying to move the selective information in the text file to Excel sheet record by record using VB.Can u help me in this regard.
The contents in text file is like:
"http://www.commerx.com/contact.html","inforequest@commerx.com"
"http://www.commerx.com/contact.html","ClientSupport@commerx.com"
"http://www.commerx.com/services-intranets.html","intranets@commerx.com"
"http://www.davacosourcing.com/company/","bignews@davacosourcing.com"
"http://www.davacosourcing.com/company/","careers@davacosourcing.com"
.
.
.
.
.
.
The above information need to be moved in Excel sheet record by record as:
http://www.commerx.com/contact.html inforequest@commerx.com
http://www.commerx.com/contact.html ClientSupport@commerx.com
http://www.commerx.com/services-intranets.html intranets@commerx.com
http://www.davacosourcing.com/company/ bignews@davacosourcing.com
http://www.davacosourcing.com/company/ careers@davacosourcing.com
.
.
.
.
..
Please do help in this regard as there are more than 1000 information that has to moved in the above pattern.
Thanx
babu
Deleting Content Of Text Box
When I delete the content of text box in a form and update the recordset... I get the next error: Multiple step operation generated errors.
However if I don't delete that content... then, the next code works perfectly.
Private Sub Command_Click()
DE.rscmdGrupos.CancelUpdate
DE.rscmdGrupos.Fields("Fechafin") = Null
DE.rscmdGrupos.Update
If Not (DEGesact.rscmdGrupos.BOF And DEGesact.rscmdGrupos.EOF) Then
DEGesact.rscmdGrupos.MoveFirst
End If
End Sub
PD.- I work all the time with Data Environment attached SQL-Server
Please, help me. Thanks
How To Scroll Text Box Content?
I WAS WONDERING HOW TO SCROLL THE TEXTBOX CONTENT WITH UP SIDE DOWN?
I HAVE ALREADY SET THE TEXTBOX PROPERTY TO MULTILINE.
THEN WHAT ELSE I NEED TO DO?
I HAVE TRY OUT USING THIS:
TEXT1.SCROLLBAR=2
BUT NOTHING HAPPEN BUT ERROR MESSAGE POP UP~
ANYBODY CAN GIVE ME A CLUE,WHAT IS THE CODING FOR SCROLLING THE TEXT CONTENT UP AND DOWN...??
Text Box Content Format
Is there a way to have the data in a text box formatted in Excel? I am pulling data from cells on a worksheet with a specific format (i.e. telephone number). But when it appears in the text box in my custom form it drops all formating. So if I update the data in the userform and try to apply the changes to the worksheet it over writes the original formatting so it's a real pain.
I need to find a way to force the Form's Text Box to alter the format of the data within it.
Any Suggestions?
Thanks,
Adam
Get Text Content Of Any Window
hi
ive searched the net and the forum for the answer, but i've found nothing,
but getting text from a window of a specific class (witch i allready know how to do).
i'm writing a screen-reader, and i need to be able to get the text content of any window the mouse pointer is over.
for ex. if a mouse is over a "document part" of the MS Word application, it gets the content of the document.
i could also live with the option of selecting the text - u guess that would be easier to do. besides ive done something simmilar in the past.
i was using GetAsyncState (or something like that) to get last pressed key (this includes mouse buttons). ive checked if the mouse was pressed, and released (with no in betwen events), and if so, i was sending "CTRL+C" and getting the selected text from the clipboard, but that is what i would like to avoid - the clipboard.
so if anyone has an idea how to achive option one or option two (same as described, but without clipboard) please share with me.
thanks in advice.
Printing Content Of Text Box
I would like to print contest of text box , but when I print it with printer object it is all in one line. I what that it looks same on paper as in text box on screen.
Thanks !
Searching For Text Files By Content
Can anyone please tell me how I can search a directory containing a number of text files and return a collection of those containing certain keywords. I have a large number of files that need to be sorted into various directories based on their content and a program to do this would be very useful.
Thankyou all
BlackDove
Text Content Of Powerpoint Document
Hi!
Can anyone give me an idea on how I will be able to extract the text content of a PowerPoint File?
A simple code in Visual Basic Would be very much apprecited.
Regards,
Ian
IANIAN
Text Box Content Comparison <RESOLVED>
I would like to ask the following question:
Suppose I have three textboxs called Text1, Text2 and Text3
In VB I do the following comparison:
VB Code:
If Text1.Text > Text2.Text Then Text3.Text = 1Else Text3.Text = 0End If
The funny situation is that:
When Text1 Textbox contains 50, and Text2 Textbox contains 6
Text3 Textbox output is 1. i.e. 50 < 6 ??
What happened on it?
P.S. I have tried using 2 Combobox as selection input and 1 Textbox as output. It is correct!!
Want To Print And Fax The Rich Text Box's Content.
Hi All,
I have created an application with a RichTextBox control on the form.
I need that user can print the content of Richtextbox.
I added Common Dialog box in my form and able to generate the print dialog box but unable to print only Rich Text box content.
Similarly if the user need to fax or email the content what control and coding i should add?
Thanx,
Saurabh
Copying Web Page Content (text)
Is there an easy way to copy the contents (text only) of a web page using the WebBrowser OCX and import it into your VB App like, for instance, into a string? Thanks in advance.
Text Box Content Based On A Combo Box
Hi guys,
dglienna (sorry for the namedropping), gave me advice about a program i'm building. its about using a combo box to access records in an access database. i tried a few basic methods that i know and tried consulting MSDN but it seems that the terms are too complicated for me.
anyway, the advice was about using a combo box to retrieve records to be edited from a database. so i decided to get the combo box to display all the surnames of each record in the database, and when the user clicks on a surname, the record that belongs to that surname is displayed on a set of text boxes. (e.i. name, department, position, employee number).
so how do i go about this? i got the combo box to display the surnames, but what about the displaying of records in the text boxes?
pls be gentle, i am a newbie to visual basic programming.
THANK YOU AND MORE POWER TO CODEGURU!
Capturing Text Content Of A Running Application
hey guys! i'm creating ang application for string processing purposes. I would like to know if it's possible to capture a text content of a currently running application (any text editor), for instance, Microsoft Word or Notepad.. or any other text editor. I would like to know if we can capture the current text content and put it in a textbox. please help. Thank you so much!! ^^
Edit by moderator:
I've moved this to the Legacy forums from .NET based on your posting history. If you truly are looking to develop this in .NET, please PM one of our moderators and we'll move it for you.
|