Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Read And Manipulate Text In Notepad


Hello

I have a bunch of files opened in notepad (15 to be exact). What I would like to be able to do is to parse the text and use what I find as the name of the file when I save it.

I'm currently using the following code to save and close the files.
Code:
For d = 0 To 15
AppActivate ("notepad")
SendKeys "%FA", True
SendKeys "SeeTriangle[" & d & "]", True
'SendKeys "%TT", True
'SendKeys "%N", True
SendKeys "%S", True
SendKeys "Y", True
SendKeys "%FX", True
SendKeys "N", True
Next
I then open them back up in my app and do the parse and save them with the new name. I would like to cut out the extra step and just parse the file in Notepad and close it with the proper name.

I haven't been able to see a way to do this so far. So, my question is, Can I parse the text in notepad?

Thanks

David




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Manipulate File In Notepad
Does anyone have any code they coudl shared. I want to open an Avaya cms script in notepad have the code change the date save and close file

How To Save/read Textbox Text To/from Notepad File
Pls show me that how to save/read textbox text to/from notepad file. urgent please help me......

Copy All Text From Textbox, Open Notepad, And Automatically Paste To New Notepad Shee
Hello everyone.

I am trying to copy all text, that is already in the textbox, to a new notepad sheet.

Example:

Step 1. Copy all text in Text1 box to clipboard.
Step 2. Open Notepad
Step 3. Paste clipboard to notepad.

All this should be done with one click of a button.

I get as far as copying everything to the clipboard, and it even opens up notepad, but I still have to manually paste (CTRL-V) into notepad.

I would even like it to ask me what name to save it as as well as where to save it at...just like the Save As function in Word or something.

Here is what I have so far.

Private Sub cmdCopytoClipboard_Click()
Dim MyAppID
Clipboard.Clear
Clipboard.SetText Text1.Text
MyAppID = Shell("NOTEPAD.EXE", 1)
AppActivate MyAppID
MyAppID = Clipboard.GetText()


End Sub

Read Data From Excel And Manipulate Checkboxes.
How am I to read ,let's say all the data in the 4th column in Excel(only the UNIQUE VALUES,NO duplication of checkbox values) and then display them (with checkboxes) in the UserForm? The checkboxes must not be hardcoded, therefore should be manipulated dynamically without overlapping one over another. If I were to click a checkbox, it has to show some values in a worksheet in a format. If I were to click more(lets say 20 checkboxes), it will show ALL 20 diff info.... But now the first problem is I do not know how to manipulate them dynamically for those unique values which are read from the 4th column in Excel 97. anyone pls help me out there....! Thanks in advance.



Edited by - Siraj on 3/11/2003 7:59:03 PM

Read From Notepad
is there a way using vb to edit the text in a notepad document, and later on view it.
example: you could enter text in a textbox and on the click of a button that text is inserted into a new line of a notepad document. also, with the click of another button, any text in the notepad document can be viewed in a listbox.

Not Able To Read The Next Line In The Notepad
problem : i want to read the next lien from a notepad which hgas a matrix for example
1 1 1
0 1 1
1 1 1
After the first loop i want the str2 to be 0 1 1 ?Ho can we do that .any pointer plz.....or if u see nay fault in my code.....reply back at your earliest convenience. thanks

Dim x, y, z As Integer
Dim fname As String, str3(10, 10) As Integer, str2 As String, col1 As Integer
fname = "C:sss1foxoutput.txt"
Open fname For Input As #3
y = 1

While Not EOF(3)
Line Input #3, str2
str2 = Replace(str2, " ", "")

For x = 1 To Len(str2)
str3(y, x) = CInt(Mid$(str2, x, 1))


Next x
y = y + 1

Wend
MsgBox str3(2, 1)

Read From XLS And Write To A Notepad
Hi,

I am trying to read from an xls file columns 1,3,4,5 and write that to a notepad excluding the headers in xls (exclude the first row). Help me out in achieving this.

I am from legacy environment. So please try to make your code with comments as far as possible. Something from the scratch would be of great help to me.

Thank You.

VB Read Notepad Then Input To Excel
Situation: am reading a Notepad file to extract data to input into an Excel spreadsheet

When I find the data I need, I use this code to put it into the spreadheet:

wkbNewBook.ActiveSheet.Range("A4").Value = Mid$(textline, 4, 2)

Looking for a way via VB code to iterate the "A4" to "A5" then "A6", etc.

Any ideas?

Please Read This About My Question About Edit In Notepad.
Make the menu on the main form as normal, but make the top-most item invisible.

Eg

mnuMyCustom "Custom Menu"
--mnuEditInNotepad "Edit In Notepad"
--mnu... "....."
--etc etc etc

Then, when you want the menu to popup - normally in a mousedown event;

PopUpMenu [formname].mnuMyCustom

Look up help for PopUpMenu for more information.
When the menu item is selected from the popupmenu any code attached to the Click event of the menu is run (as normal). However, this isn't ideal as you normally want to write the code in the function that pops the menu up - in that case this is what I do..

On the form where the menu is (normally the main form) - for this example it is frmMain.

Public MenuSelected as Integer

In each click event of the items on the customer menu;

MenuSelected= [unique number]

In the code where you want the menu to popup;

frmMain.MenuSelected=-1
PopUpMenu frmMain.mnuMyCustom
select case frmMain.MenuSelected
case -1
(no items were selected from the menu)
case 1
(do whatever you want the menu item where you set menuselected=1 to do)
case 2
....

etc

End Select


Hope this make sense..

------------------
Mark "Buzby" Beeton
VB Developer
BuzbyB@HotMail.Com

Able To Read My Binary File In Notepad?
I've been experimenting with binary files and noticed that the file I created in "binary" mode, is readable in notepad? I thought that this mode put every character in terms of a "0" or "1"? Or maybe I'm doing something wrong..

I created a UDT... myRecord
...

' add some strings to myRecord
...
Open myfile for binary as #1
put #1,, myRecord
close #1

....

(I'm trying to protect sensitive data. Next step is encryption.)
any help is appreciated!

Kenny

VB Read Notepad Then Input To Excel
Situation: am reading a Notepad file to extract data to input into an Excel spreadsheet

When I find the data I need, I use this code to put it into the spreadheet:

wkbNewBook.ActiveSheet.Range("A4").Value = Mid$(textline, 4, 2)

Looking for a way via VB code to iterate the "A4" to "A5" then "A6", etc.

Any ideas?

Text Manipulate Help
Hi peeps,

Trying to remove extra spaces in file, any ideas as to why this doesn't work?


Code:
Dim strData As String
Dim bytData() As Byte
Dim Length As Integer

Open SelectedFileName1 For Binary Access Read As filenumber
ReDim bytData(LOF(filenumber) - 1)
Get #filenumber, 1, bytData()
Close filenumber
strData = StrConv(bytData(), vbUnicode)
DoEvents
Erase bytData()

Do While InStr(strData, String(2, " ")) > 0
strData = Replace(strData, String(2, " "), " ") 'REMOVE EXTRA SPACES
DoEvents
Loop
Debug.Print strData


Many thanks.

Read 1 Line At A Time From A Notepad File
Hello,

I am making a program that I need to read 1 line of text from a notepad.exe file...

The current code I am using is:


VB Code:
Private Sub Command4_Click()Dim strLine As String Open App.Path & "/myFile.txt" For Input As #1  While Not EOF(1)    Line Input #1, strLine    Text1.Text = strLine   WendClose #1End Sub


Now everytime I click on command4 I need the program to go to the next line of text in the app.path /myfile.txt and display it in the text1 text box...

How do I get it to read and output line 1 and then when I click it again read and output line 2, and so on?

Thanks and let me knwo if you need any more info!

Manipulate Text File
I saw this example in another thread and decided it would make a good example for me to learn VBs file manipulation syntex. That thread is closed so I was asked to start a new thread.

Lets say this data was in a file and it had numerous records. I think I'm close down there, but am doing something wrong. Thanks!

ps. I guess what I'm trying to come up with is a standard way to open and write a file, and use the middle area to manipulate the text.

MyString.txt.

1This is the string I want to keep.****12/1/2006 USG8503
2This is the string I want to keep.****12/1/2006 USG8503
3This is the string I want to keep.****12/1/2006 USG8503
4This is the string I want to keep.****12/1/2006 USG8503

[highlight=VB]
Private Sub cmdClick()

Dim sFileInfo() As String
Dim i As Long

Open "C:MyString.txt" For Input As #1
sFileInfo(i) = Left$(i, Len(i) - 21)
Close #1

Open "C:AllFixedUp.txt" For Append As #1
Print #1, sFileInfo(i)
Close #1

Next
End Sub

Text Manipulate Problem, Please See
I have text like this example:


Text1.Text = "123:0002300:00:123456:789102"
So i need to se in Text2.Text only this,
Text2.Text= "123456789102" without chr " : "

This is not problem to make, but somtime Text1 i larger than previous
and look like this,

Text1 = 125:0000000789:00:354786:AF564B
How can I now put 354786AF564B in Text2 ?

B.R
VB Client / Server

How To Manipulate Text In MSOutline?
Hi,

I am using Microsoft Outline control on my project and I would like to be able to manipulate the color of the text that is display in the outline, i.e., I have five line of texts in the outline and I want the line with the word "Me" to be display in red and the rest to be display in black. Can I do this and how? I tried this line of code:

frmMe.OutLine.forecolor = "&HFF&"

and everything in the outline turn red, but if I tried this:

frmMe.Outline.strString.forecolor = "&HFF&"

(where strString is the string that I want to be displayed in red) the project just hang there and nothing happen. TIA

How To Manipulate Text In MSOutline ???
Hi,

I am using Microsoft Outline control on my project and I would like to be able to manipulate the color of the text that is display in the outline, i.e., I have five line of texts in the outline and I want the line with the word "Me" to be display in red and the rest to be display in black. Can I do this and how? I tried this line of code:

frmMe.OutLine.forecolor = "&HFF&"

and everything in the outline turn red, but if I tried this:

frmMe.Outline.strString.forecolor = "&HFF&"

(where strString is the string that I want to be displayed in red) the project just hang there and nothing happen. TIA

How To Manipulate In-cell Selected Text
Hi,

Is it possible to retrieve the selected text (characters, not entire cell!) in a cell? Apparently Excel disables all macros when the cursor is inside a cell.

Cheers,

Guillermo

Manipulate Email Message Text
Hi All,

I am looking for a tutorial or example of how to look for a particular email in a folder not necessarily inbox and pull info
from that email to be inserted into a table.

If anyone has any ideas, any help would be most appreciated.

Thanking you in advance.

How To Manipulate Text In Microsoft Outline ?
Hi,

I am using Microsoft Outline control on my project and I would like to be able to manipulate the color of the text that is display in the outline, i.e., I have five line of texts in the outline and I want the line with the word "Me" to be display in red and the rest to be display in black. Can I do this and how? I tried this line of code:

frmMe.OutLine.forecolor = "&HFF&"

and everything in the outline turn red, but if I tried this:

frmMe.Outline.strString.forecolor = "&HFF&"

(where strString is the string that I want to be displayed in red) the project just hang there and nothing happen. TIA

Manipulate Text In Ms Word Cells
This is my first vb code. i keep getting error 448. I simply want to modify the text in the cells in column one to shorten them by 3 characters.

Set aColumn = ActiveDocument.Tables(1).Columns(1)


i = 1
For Each aCell In aColumn.Cells
c1 = aCell.Range.Start
c2 = aCell.Range.End - 3
Set myRange = aCell.Range.Text(Start:=c1, End:=c2)

aCell.Range.Text = myRange
i = i + 1
Next aCell

The error occurs with the set myRange line. Help.

Notepad Like Text Box.
I want to use a Notepad like text box on my form, not the VB text box. Because there is some data in my application which is displayed correctly on Notepad, but not on my VB text box.
For example, try putting this text box on VB text box, Rich text box and Notepad. You will see the difference.
-----------------------------------
qANQR1DBw04DUMs5Cb82FW
+3r1dzx2KyJGzz2+dJNfdF
4stIu2LPk0ZGUrhZVLe6PF
BzE3HKNHCQFkCgWMmDEmop
+mX3Qy9eHNg61VAATWGU41
------------------------------------

Text To Notepad
yes, i want to know how i can take textbox text from a form and put it all into notepad so it is ready to print or even open in a seperate form ready to print, either one will work.

Notepad Like Text Box.
I want to use a Notepad like text box on my form, not the VB text box. Because there is some data in my application which is displayed correctly on Notepad, but not on my VB text box.

Any Idea?
..........
Rohit.

(Pending Research) How To Read To End Of Line "Notepad Application"
I'm working with Gerber files and trying to re-format the files to an Excel workbook and five worksheets. Worksheets are going to be named "Top Copper", "Bottom Copper", "READ-ME", "Drill" and "Data Ready".

To import the data straight to Excel is fairly easy to do, but I need to use a program to place parts of the file into sections "cells" and "rows". I haven't been able to code a program to define a logic statement agreement to impliment this yet.

Heres just one example.


Code:
X-1800Y+3000D01*


You see a line of G-code. All lines consist of X and Y" in some state, where "X" can be -X, +X and "Y" can be -Y, +Y.

My idea is to do something as follows:

(A1,1) = X-
(B1,1) = 1800 "Note leading zeros are suppressed"
(C1,1) = Y+
(D1,1) = 3000 "Note leading zeros are suppressed"
(E1,1) = D03
Some ideas? I tried using "If" statements, but that just returned the string. I'm now trying to use a set of case statements, but that seems to make the the problem harder. Now the code is very large and without problem solving capabilities included, such as (E1,1).

I having so many problems with all the different things going on with the format that I don't know where to start coding the application - Please refer to my other thread of the g code sample.

Opening Text In Notepad Help
Hello, i'm wondering how to display the notepad ontop of programs running, currently, it goes in the backround, anyway to do this? I use the following code to open notepad and my text file in the same directory as program.


Code:
bool = Shell("notepad textfile.txt")

NotePad To Rich Text Box
Hi,

I was hoping someone could help me figure out how to display text from a notepad file within a rich text box in visual basic. I have absolutely no idea where to begin.

Thanks!!

Send Text To Notepad
hi there,
I'm working on this program using speech command. And what i would like to do is send any word said by the user to notpad. I was thinking about using getfocus, or setfocus, or senmessage, but i don't have any good idea yet.
does anyone has a thought about it?
thanks.

Help Searching The Text In A Notepad
can someone help me pls
how can i search the text in the notepad then display the whole line next to it in a textbox

example:the word below is the text written in a notepad

start
the quick brown fox
jump over the lazy dog
and so what
end

i want to search only the word jump but i want to display the whole line, how can i display the word jump over the lazy dog in a textbox

thanks!!!!!

i hope you understand

sorry for my poor english

Copying Text Into Notepad
hi

I am an absolute novice in Vb.
Had a small problem.
I enter certain data in the text boxes.How do i capture this data and store it in a notepad.

For example:The user form looks like this

length:
breadth:
height:

The values eneterd into these textboxes need to be saved in a notepad in the following format

assembly_length=text1.text
assembly_breadth=text2.text
assembly_height=text3.text

thanks
mridz

Sending Text To Notepad
I have notepad open a and the title of the window is "Untitled - Notepad" . Is there any way I could send a string to notepad (eg type into notepad)?

Deleting Text In A Notepad .txt From An App
how do i delete text inside a notepad file from my app? i have this code...

Private Sub cmdclear_Click()
Dim iFileNum As Integer
iFileNum = FreeFile
Open App.Path & "folder ext.txt" For Append As iFileNum
Print #iFileNum, ""
iFileNum = ""
Close iFileNum
End Sub

...but it doesn't work. can someone please revise my code?
thanks in advance.

Pulling Text Out Of Notepad
Does anyone know of a functional way to pull the text out of the edit control in Notepad when it's open. I can get the hWnd of Notepad and the single edit control it contains (by using FindWindowEx twice), but I can't seem to get the text. Someone mentioned to me that GetWindowText would work on anything that had a text property, but it won't get the text in the edit control. I also tried using SendMessage and the constant WM_GETTEXT, but that doesn't work either (using WM_GETTEXTLENGTH to get the size of the buffer I need however does, which is odd). The only other way I did it was really complicated, and I never got it to work, but basically it went on a line by line basis extracting single lines at a time from the box. Both that way and the WM_GETTEXT one were crashing VB, and I didn't see what could be causing it.

Exporting Text Box Text To Notepad
hi
is there a way to export textbox text to notepad

eg:

text1.text= a whole bunch of stuff

text1.text=""

text1.text= another whole bunch of stuff

and the notepad file displays
:a whole bunch of stuff
another whole bunch of stuff



thks in advance for helping me out guys

Text Color [ ASP-Notepad Project ]
Hi!

Im making a ASP-Notepad kinda program and i just need to know how to make everything between <% and %> in a different color.

ASP File:

<font face="verdana">Time is:</font> <-- This text in normal color.
<% =Date %> <-- This text is going to be in, hmm, red color.

Thanks!

Open Text File With Notepad
I would like to open a text file with notepad or wordpad. I tried the shell-function. But that doesnt work.

bool = Shell(notepad "hallo.txt")

It once worked but I forgot how...
Please help!

Anita

Display Text Data In Notepad From VB
I need to show a user some data straight from a text file seperate from the VB program itself. I realize I can shell with either...

"notepad file.txt"
or
"start file.txt"

... with the "start" command using the Windows Run command, which uses the default program for a txt file. So it seems the later would be best, but I don't know if this "start" command works for Windows XP and Windows 2000 -- does it? Or are there different concerns I should have using the "start" command. Or is the "notepad" command better?

Thanks for any insight you can give, or if I should do something different.

Opening A Text File Using Notepad
I've made a help text file that I want to be accessed through the menu, and when the menu item is clicked. I'd like the text file to be opened in Notepad while my Visual Basic program is still running, similar to what would happen if you double clicked the text file in Windows Explorer. What sort of syntax do I need to use?

Printing Desired Text Into Notepad....
This opens up the notepad file with my desired name, what I want to do next is have visual basic print text into the notepad file.


Code:
Dim dTaskID As Double, path As String, file As String
path = "C:WINDOWS
otepad.exe"
file = "C:Team Template.dat"
dTaskID = Shell(path + " " + file, vbNormalFocus)
End


Basically, I have a simulation sports game that uses modifiers read from a .dat file that are read as variables after being opened and used in a serious of dice rolls and equations.

I want to provide a way for players to create their own teams (.dat files) and the text that will show up in the notepad file will be a guideline of what information they need to provide.

Ideally, a notepad opens up with this printed:
Team Name,0,0,0,image.bmp


Thanks in advance, I don't start my game and simulation degree until this summer and I've only got 3+ years of self taught VB knowledge.

Open A Text File (in Notepad) From VB
Hello,

I want to open a specific text file from within VB. For example, by clicking a button. I have tried ShellExecute..but it does not seem to work.

Help.

Thanks!

Writing Text To Notepad (Resolved)
Hi Team

Does anyone know how to write directly to Notepad. I want to output the results of a search directly to the screen in a form that the user can then either print or save. I don't want to create a text file and then display it. Rather, I want to create an instance of Notepad and then write to it.

This is what I have so far!
VB Code:
Option ExplicitPrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPrivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongPrivate lngNotepadHandle As LongConst WM_SETTEXT As Long = &HC    Friend Sub PrintLine(Line As String)    Dim hEdit As Long        hEdit = FindWindowEx(lngNotepadHandle, 0&, "Edit", vbNullString)    SendMessage hEdit, WM_SETTEXT, 0&, ByVal LineEnd Sub Friend Sub CreateNotepad()    Shell "notepad", vbNormalFocus    lngNotepadHandle = FindWindow("notepad", vbNullString)End Sub

Calling CreateNotepad creates an instance of Notepad and PrintLine outputs a line. But each call of PrintLine replaces any existing Notepad text with the Line. Does anyone know how to change the PrintLine function so that it will append to the existing text rather than replacing existing text?

Thanks

FW

Open Text File In Notepad
My application generates a number of .Log files. All are standard text files that I can easily view in Notepad. What I'd like to do is add a menu item which, from within my program, my user to open them and view them, in notepad. I've tried:
VB Code:
Shell "c:myfoldermylog.log", vbNormalFocus'and I have triedShell "notepad.exe c:myfoldermylog.log", vbNormalFocus
And neither one works. What am I doing wrong?

Shell Notepad With Text1.text
i want to shell notepad with text1.text. any help would be great

Deleting Text In Notepad From My Vb6 Program...
hello,

is there any way that I can delete text in notepad from my vb6 program?

thnx

DFLW

Open Text File With Notepad??
I've tried to open the text file with notepad with the
following command


ShellExecute(Me.hwnd, "open", "c: emp
eadme.txt", 0&, 0&, SW_SHOWNORMAL)

but it wouldn't do anything, I'm pretty sure in the register, the txt file is associated with notepad

Any idea?

Thank you in advance for any help!!

Printing Encrypted Text To Notepad
I am coding settings for my program and it will load the settings on program load and save the settings on program close. Some of these are encrypted and decrypted and thats what I am having a problem with.

Declarations:
Code:
Private TheLines() As String
Private FileContents As String
Private File As Integer


Encryption:
Code:
Public Function Encrypt(Text As String) As String
Dim I As Integer
Dim C As Integer
Dim Temp As String
Temp = ""
For I = 1 To Len(Text)
C = Asc(Mid(Text, I, 1))
C = C + 10
If C > 255 Then C = C - 255
Temp = Temp & Chr(C)
Next I
Scramble = Temp
End Function

Public Function Decrypt(Text As String) As String
Dim I As Integer
Dim C As Integer
Dim Temp As String
Temp = ""
For I = 1 To Len(Text)
C = Asc(Mid(Text, I, 1))
C = C - 10
If C < 0 Then C = 256 + C
Temp = Temp & Chr(C)
Next I
UnScramble = Temp
End Function


Settings:
Code:
Public Function SaveSetting()
Open App.Path & "Settings.txt" For Output As #File
Print #File, Form2.Option1.Value
Print #File, Form2.Option2.Value
Print #File, Form2.Option3.Value
Print #File, Form2.Check1.Value
Print #File, Encrypt(Form2.Text1.Text)
Print #File, Form2.Check2.Value
Print #File, Encrypt(Form2.List1.Text)
Print #File, Encrypt(Form2.Text2.Text)
Close #File
End Function

Public Function GetSetting()
Open App.Path & "Settings.txt" For Input As #File
Form2.Option1.Value = TheLines(20)
Form2.Option2.Value = TheLines(21)
Form2.Option3.Value = TheLines(22)
Form2.Check1.Value = TheLines(23)
Form2.Text1.Text = Decrypt(TheLines(24))
Form2.Check2.Value = TheLines(25)
Form2.List1.Text = Decrypt(TheLines(26))
Form2.Text2.Text = Decrypt(TheLines(27))
Close #File


When I run my program, I then try and add some settings. When I close the program I look at the text file which has been created and it has not added the encrypted text. I don't know why it is not printing it.






Edited by - Rapidfire on 5/7/2007 9:28:25 AM

Notepad Application:dragging Text Files?
i am developing a notepad application, and i was wondering if i can open text files that are lying on my desktop by dragging it into my application's workspace.

how do i do it?

Saving Text To A Notepad Document From Textboxes
bit off the topic, but what's the difference between the Write and Print?

Saving Text To A Notepad Document From Textboxes
Hi

I need some help on making the text boxes in my form, that each will have data in, when the user clicks the button SAVE it will save the data to a notepad document. ??? Please Help!

Copyright © 2005-08 www.BigResource.com, All rights reserved