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




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?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
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?

Populating Grid By Taking Input From A Notepad
Problem..
I have a output text file which has 1 and 0s in it. I want to read that notepad and wherever there is a zero I want to gray out the corresponding gray cell in the grid which is of teh same size as the matrix.

eg of notepad 1 1 1
0 1 1
0 0 1
now where ever we have zeroes we want to gray out the corresponding location in the grid....
eg in above case need to gray out grid(2,1),grid(3,1), grid(3,2)?.for a 2X2 matrix we have 2X2 GRID ,3X3 MATRIX 3 X 3 GRID AND SO ON ?TILL 5X5
Can you please point out teh mistakes in my code.....
i MA TRYING TO CAPTURE THE OUTPUT IN an array
Code:
dim i As Integer, j As Integer, col1 As Integer
Dim fname As String, str2 As String, str3(i, j) As String
fname = "C:sss1subsoutput.txt"
Open fname For Input As #3
While Not EOF(3)
Line Input #3, str2
str3(i, j) = Split(str2, "tab(1)", -1, 1)
For i = 1 To 5
For j = 1 To 5

If str3(i, j) = 0 Then
gridSignatureConstraints.TextMatrix(gridSignatureConstraints.Row, gridSignatureConstraints.Col) = str3(i, j)
gridSignatureConstraints.CellBackColor = gridSignatureConstraints.BackColorFixed
End If
Next j
Next i
Wend
Close #3
End Sub

How Do I Switch To Notepad, And Carry Out Some Data Input
Ok,

I have a simple button on the form, and when I click that button, I would like the program to switch to notepad, that I already have open, and enter the workd "Hello". I've got the below from API Network, but it doesn't switch to notepad? Any ideas whats wrong please

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1


Private Sub cmdinput_Click()
Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
'Ask for a Window title
Ret = "Untitled - Notepad"
'Search the window
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
'Show the window
ShowWindow WinWnd, SW_SHOWNORMAL
'Create a buffer
lpClassName = Space(256)
'retrieve the class name
RetVal = GetClassName(WinWnd, lpClassName, 256)
'Show the classname
MsgBox "Classname: " + Left$(lpClassName, RetVal)
'Post a message to the window to close itself

End Sub

The msgbox returns and tells me the Name of the window ok, but it just doesn't switch to it?

Any Help Appreciated.

Thanks

Mabsey

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.

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

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

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!

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......

Convert Excel To Notepad
I have an excel file that is divided into multiple sections. I need to create a txt file to transfer to another system from that excel file. Basically I will look at each section and only pull out the necessary info if any ( I have this done now).

Then that would get pasted into notepad and saved as the excel name.

I am using the Shell to open notepad.

My question is, should I just collect all the info and paste it at once or one line at a time?

The only worry with all at once is I will need to keep a format in the txt file (columns) and not 100% sure how to do that. Do I just add a return character once I have collected all the data for that line?

Thanks this forum is the BEST!!!

Application Using Excel, Notepad And Vb6
Hi guys, I have just started programming with Visual Basics v6. I am trying to write a program that allows me to read data from five Gerber.txt files and import the data to an Excel workbook.

My first problem is reading the notepad file the Gerber makes. I can open them, but I can't read the data and organise the data types in any format, or infact close the files afterwards.

Heres the start for the code;
Code:
Private Sub Control_Click()

Dim FileName As String
Dim DFileName As String
Dim TFileName As String
Dim BFileName As String

BFileName = ("C:Program FilesLabcenter ElectronicsProteus 7 ProfessionalSAMPLEScontroller1 - CADCAM Bottom Copper")
TFileName = ("C:Program FilesLabcenter ElectronicsProteus 7 ProfessionalSAMPLEScontroller1 - CADCAM Top Copper")
DFileName = ("C:Program FilesLabcenter ElectronicsProteus 7 ProfessionalSAMPLEScontroller1 - CADCAM Drill")
FileName = ("C:Program FilesLabcenter ElectronicsProteus 7 ProfessionalSAMPLEScontroller1 - CADCAM READ-ME")

Shell "notepad.exe " & FileName, vbNormalFocus
Shell "notepad.exe " & BFileName, vbNormalFocus
Shell "notepad.exe " & TFileName, vbNormalFocus
Shell "notepad.exe " & DFileName, vbNormalFocus

End Sub

Here is a sample of a simple file that I want to arrange;
Code:
G04 PROTEUS RS274X GERBER FILE*
%FSLAX24Y24*%
%MOIN*%
%ADD10C,0.0120*%
%ADD11R,0.0800X0.0250*%
%ADD12R,0.0800X0.0800*%
G54D10*
X+0Y+0D02*
X+0Y+936D01*
X-116Y+1336D01*
X+883Y+1336D02*
X+867Y+936D01*
X+867Y-986D01*
X+1650Y-986D01*
X+2050Y-1000D01*
X+2050Y-1375D01*
X+2050Y-1500D01*
X+400Y-1500D01*
X+0Y-1500D01*
X+2050Y+0D02*
X+1930Y+125D01*
X+1930Y+936D01*
X+1883Y+1336D01*
X+2050Y-500D02*
X+2914Y-500D01*
X+2914Y+936D01*
X+2883Y+1336D01*
X-1534Y+1336D02*
X-1534Y-474D01*
X-400Y-474D01*
X+0Y-500D01*
G54D11*
X+0Y+0D03*
X+2050Y-1500D03*
X+0Y-500D03*
X+2050Y-1000D03*
X+0Y-1000D03*
X+2050Y-500D03*
X+0Y-1500D03*
X+2050Y+0D03*
G54D12*
X-116Y+1336D03*
X+883Y+1336D03*
X+1883Y+1336D03*
X+2883Y+1336D03*
X-1534Y+1336D03*
X-2793Y-1655D03*
X-2793Y-655D03*
X-2793Y+344D03*
X-2793Y+1344D03*
M00*


One of my first objectives is to convert the data files to a format that my homemade PCB router will understand. I need to organise the data files so that my router will know were the cutting tool should be in relation to the code. At the moment the file formats are for a photoplotter pen.

To make this work properly I need to read a READ ME file first, so that the program will know what parts of the data files needs a conversion.

Here is the file that I'm using the setup the data conversions correctly;

Code:
LABCENTER PROTEUS TOOL INFORMATION FILE
=======================================

In case of difficulty, please e-mail support@labcenter.co.uk

Tool set up for Proteus layout 'controller.LYT'.
CADCAM generated at 10:07:17 AM on Monday, March 24, 2008.

File List
---------
Top Copper : controller1 - CADCAM Top Copper.TXT
Bottom Copper : controller1 - CADCAM Bottom Copper.TXT
Drill : controller1 - CADCAM Drill.TXT

Photoplotter Setup
------------------
Format: RS274X, ASCII, 2.4, imperial, absolute, eob=*, LZO
Notes: D=Diameter, S=Side, W=Width, H=Height

D10CIRCLED=12th DRAW
D11SMTW=80th H=25th FLASH
D12SQUARES=80th FLASH

NC Drill Setup
--------------
Format: ASCII, 2.4, imperial, absolute, eob=<CR><LF>, no zero suppression.
Notes: Tool sizes are diameters. Layer sets are in brackets - 0=TOP, 15=BOTTOM, 1-14=INNER.

T0140th (0-15)


[END OF FILE]


I'd greatly apprecate the advise and some pointers about how I should proceed with some code.

Interaction Between Excel, Word...Notepad
I was wondering if there can be a marco made that opens a Word or Notepad file from Excel and transfers data that i have coppied from Excel to the newly opened different program. Then i need to save that new file just as .txt
The problem is that it need to do all of those actions automatically..Does anyone know if this can be done?

Thanks in advance!

(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.

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

VB: Opening CSV File In Excel Versus Notepad
My application opens a CSV file in Excel but because of some of the values it reads the values incorrectly. For example, if you open the CSV file in notepad there is a value '71902E10' that translates to 7.19E+14 or 719020000000000. How can I get it to translate properly to 71902E10. Can I format the cells before it opens? Or should I open it in notepad and process that way. If so how can I open a csv file in notepad when it automatically wants to open in excel? I'd rather be able to format and use excel if possible...

Vbscript - Copy Data From Notepad To Excel
Hi

Could someone please provide me with sample vbscript code that loads all the data from my notepad file into an excel workbook. I am finding it very hard to do as I am new to this.

thx

Read Keyboard Input
How do I let a form or to be specific a textbox check if the enter key was pressed.

Why Does Input Not Read My Commas??
The text file that is read looks like this:

http://www.google.com,Google
http://www.dustin.se,Dustin
http://www.dmicrosoft.com,Microsoft

When I take that data and put it in to a single string all the commas is left out, why?? I need them...

The split does of course not work because there is no commas left

Code:
Option Explicit
Dim aryInternet() As String

Public Function ReadUserInternetFile()

Dim tmpString As String
Dim tmpToSplit As String
Dim FileNum As Integer

FileNum = FreeFile

Open "c:merlinurl.txt" For Input As #FileNum

Do While Not EOF(FileNum)

    Input #FileNum, tmpString
    tmpToSplit = tmpToSplit + tmpString
Loop

Close #FileNum

aryInternet = Split(tmpToSplit, ",")

ReadUserInternetFile = UBound(aryInternet) - 1

End Function
[/coude]

Yours, Jonas

Simple: VB Scipt In Notepad To Open An Excel Document.
I've never written any VB ouside of VBA for excel so i'm completely lost. It is a very simple procedure, but i know nothing of VB syntax. This will be my starting point. If i have a filepath and a filename, what is the correct script to open the document??? It is an excel file.

Thanks for your help.

jpc

Writing Data From Excel To Notepad With Custom Filenames?
Hi, I'm new to this forum, and I've searched but I don't think a similar topic exists.

Suppose I have an excel spreadsheet, and I have columnes of data. The first two rows of each column contains information regarding where the column of data is from. What I would like to do, is simply to copy the entire column (except the first two rows) into a notepad document, and when saving that notepad document, naming it the names in the first two rows. Also I need to save the file not as a txt file as the notepad default, but as something else, for example, .crw

For example, if my column is
A
B


Data
Data
Data
.
.
.


I would like to have all the Data copied into a notepad document, and have it named A B.crw

I have a lot of columns to work with, so can anyone give me hints on how such a macro should be written? Thanks

Read Input From Sound Card
I am trying to read 5 tone signals (radio signals) from the sound card. I havent really any idea how to go about doing this.

If anyone has any ideas, relevant websites etc which will
start me off please let us know....

any help appreciated

Read Text File For Input !
Hello All,

I need to read text file "DBPath.txt" which contains "\ServerdAAIZealfRegistration.mdb" line written into it.

How to read that text file to get that line into string variable "strDBPath" ?

How Do U Create Input Control???? Read!!
hi there i have a form with 2 textboxes and a button. One for numerical input and another for text input and an enter button to go to another page. The thing is i dunno how to create conditional code for the button which checks the input of the textboxes.

basically I want one textbox to take numerical input and another to take character text. If numerical input is put into the character text box, then the program will output msgbox saying input is wrong??? N e help will b appreciated

thanx

Read Input From A Handheld Scanner
Hi all VB guru,

Does anyone know how to read input from a handheld scanner into a field in a VB program. That is, the scanner will capture a barcode and data will appear on a text field in a VB program.

Thanks,

Aaric

Notepad Slaughtering Layout/Excel Can't Handle Large Data
Hi all,
 
 I'm trying to send a whole bunch of data from an array in a vba macro to a tab delimited file. Originally I tried just throwing it into notepad, but I wasn't getting the right formatting. After about 1000 characters the line is hard breaked, and I can't type anything after that point. So I get "enter"s where I don't want them. I don't think my code was doing it because I have it looping at the point where it is breaking and there isn't a break every loop, just after about 1000 characters. (It's not always 1000 though, sometimes it's more, sometimes less, by hundreds, so I don't think its a character limit in notepad either)

Sub FormatDataNtP(dataArray() As Double, n_nx As Double, n_ny As Double, savepath As String)
'Puts the data into a format that can be read by MatLab
'Creates file same as the one that Solarius SolarMap makes

Dim i As Double, k As Double
Dim cY As Double, cX As Double, cD As Double

Open savepath For Output As #1

cY = 0
cX = 0
cD = 1

Print #1, "DATA ÎIŸjH”"
Print #1, Chr(9);
For i = 1 To n_nx
    Print #1, Trim(Format(cX, "#0.000000")) & Chr(9);
    cX = cX + 100
Next i

For i = 1 To n_ny
    Print #1,
    Print #1, Trim(Format(cY, "#0.000000")) & Chr(9);
    For k = 1 To n_nx
        Print #1, Trim(Format(dataArray(cD), "#0.000000")) & Chr(9);
        cD = cD + 1
    Next k
    cY = cY + 100
Next i

Close
End Sub


So I decided to do it by putting all the data into excel and then saving as a .txt file. It worked great on small files, perfectly actually. However, when I went to use my program on an actual file (I'm converting from .oms to .txt) I discovered that Excel has a column limit of 256 columns, my data has 31100. So excel can't handle it.

Any ideas anyone? I just need a program or a trick so I can get a ton of data (30000 columns vs 30000 rows) into a tab delimited format.

Thanks
                                       luka009



Edited by - luka009 on 12/1/2005 1:03:08 PM

Why Won't This Input Code Work? It Won't Read More Than 1 Line?
Hello..

I have this input code, and it won't read more than one line for some dumb reason. Can somebody please help? Thanks.


Code:
Open App.Path & "customcommands.dat" For Input As #2
Dim tLine As String
Do While Not EOF(2)
Input #2, tLine

'now we have to get, and interpret these results.
Dim WhereIsIt1 As Integer

Dim WhereIsIt2 As Integer
Dim WhereIsIt3 As Integer

Dim WhereIsIt4 As Integer
Dim WhereIsIt5 As Integer

Dim WhereIsIt6 As Integer
Dim WhereIsIt7 As Integer

Dim WhereIsIt8 As Integer
Dim WhereIsIt9 As Integer

Dim WhereIsIt10 As Integer
Dim WhereIsIt11 As Integer

Dim WhereIsIt12 As Integer
Dim WhereIsIt13 As Integer

Dim FilePath As String
Dim TheCommand As String
Dim Variation1 As String
Dim Variation2 As String
Dim Variation3 As String
Dim Variation4 As String
Dim SayThis As String

If tLine = "" Then
Exit Sub
End If

WhereIsIt1 = InStr(1, tLine, ",", vbBinaryCompare) - 1
FilePath = Left(tLine, WhereIsIt1)
'MsgBox FilePath

WhereIsIt2 = InStr(WhereIsIt1, tLine, ",", vbBinaryCompare) + 1
'MsgBox WhereIsIt2
WhereIsIt3 = InStr(WhereIsIt2, tLine, ",", vbBinaryCompare)
'MsgBox WhereIsIt3
TheCommand = Trim(Mid(tLine, WhereIsIt2, WhereIsIt3 - WhereIsIt2))
'MsgBox TheCommand

WhereIsIt4 = InStr(WhereIsIt3, tLine, ",", vbBinaryCompare) + 1
'MsgBox WhereIsIt4
WhereIsIt5 = InStr(WhereIsIt4, tLine, ",", vbBinaryCompare)
'MsgBox WhereIsIt5
Variation1 = Trim(Mid(tLine, WhereIsIt4, WhereIsIt5 - WhereIsIt4))
'MsgBox Variation1

WhereIsIt6 = InStr(WhereIsIt5, tLine, ",", vbBinaryCompare) + 1
'MsgBox WhereIsIt5
WhereIsIt7 = InStr(WhereIsIt6, tLine, ",", vbBinaryCompare)
'MsgBox WhereIsIt6
Variation2 = Trim(Mid(tLine, WhereIsIt6, WhereIsIt7 - WhereIsIt6))
'MsgBox Variation2

WhereIsIt8 = InStr(WhereIsIt7, tLine, ",", vbBinaryCompare) + 1
'MsgBox WhereIsIt8
WhereIsIt9 = InStr(WhereIsIt8, tLine, ",", vbBinaryCompare)
'MsgBox WhereIsIt9
Variation3 = Trim(Mid(tLine, WhereIsIt8, WhereIsIt9 - WhereIsIt8))
'MsgBox Variation3

WhereIsIt10 = InStr(WhereIsIt9, tLine, ",", vbBinaryCompare) + 1
'MsgBox WhereIsIt10
WhereIsIt11 = InStr(WhereIsIt10, tLine, ",", vbBinaryCompare)
'MsgBox WhereIsIt11
Variation4 = Trim(Mid(tLine, WhereIsIt10, WhereIsIt11 - WhereIsIt10))
'MsgBox Variation4

WhereIsIt12 = InStr(WhereIsIt11, tLine, ",", vbBinaryCompare) + 1
'MsgBox WhereIsIt12
WhereIsIt13 = InStr(WhereIsIt12, tLine, ",", vbBinaryCompare)
'MsgBox WhereIsIt13
SayThis = Trim(Mid(tLine, WhereIsIt12, WhereIsIt13 - WhereIsIt12))
'MsgBox SayThis

Variation1 = "computer " & Variation1
Variation2 = "computer " & Variation2
Variation3 = "computer " & Variation3
Variation4 = "computer " & Variation4
TheCommand = "computer " & TheCommand

If Variation1 <> "" And Variation2 <> "" And Variation3 <> "" And Variation4 <> "" Then
If Results = TheCommand Or Results = Variation1 Or Results = Variation2 Or Results = Variation3 Or Results = Variation4 Then
RCA.Voice.Speak SayThis
Shell (FilePath)
End If
Close #2
Exit Sub
End If

If Variation1 <> "" And Variation2 <> "" And Variation3 <> "" And Variation4 = "" Then
If Results = TheCommand Or Results = Variation1 Or Results = Variation2 Or Results = Variation3 Then
'do something
End If
Close #2
Exit Sub
End If

If Variation1 <> "" And Variation2 <> "" And Variation3 = "" And Variation4 = "" Then
If Results = TheCommand Or Results = Variation1 Or Results = Variation2 Then
'do something
End If
Close #2
Exit Sub
End If

If Variation1 <> "" And Variation2 = "" And Variation3 = "" And Variation4 = "" Then
If Results = TheCommand Or Results = Variation1 Then
'do something
End If
Close #2
Exit Sub
End If

If Variation1 = "" And Variation2 = "" And Variation3 = "" And Variation4 = "" Then
If Results = TheCommand Then
'do something
End If
Close #2
Exit Sub
End If

Loop

Close #2

and I know there is probably a more efficient way to do this, but I don't really want to do it any better way. Please just tell me why it won't read more than the first line... Thanks

-compuXP
www.vibewave.com

Read MSCOMM Input Buffer Without Emptying It
Is there anyway I can read a byte from the MSCOMM input buffer without removing that byte?

Shelled Program Cannot Read Input Files.
So I have my C++ program, compiled as an .exe

I use Shell or some other method to run the exe from VB.

Thing is that my .exe reads data from some data files, and for some reason, when i run it from shell, it can't seem to read the data.

for example, it reads a variable "numReplications" from a text file, or it is supposed to. This works when i run it from the command line or if i just click on it in windows.

when i run it from VBA in Excel, the variable is assigned a huuuge value of 4226292.

When i delete the data files and run the .exe from the command line, the variable is assigned the value of 4226292 as well.

the path for reading the text file is not explicitly specified within my compiled C++ code. the text file is simply in the same directory as the .exe file.

Problem To Read Minimum Value Of Input File
I have a program to read 5000 points of xyz coordinates. I'm using the code below to read and calculate the minimum and maximum value of the coordinates but the code doesn't seems to give the correct output. It didn't display the correct xmin and ymin. Can anybody help to see what wrong with the code or maybe suggest a better way to do this? Thanks a lot


VB Code:
npnt = 1 Open "c:PSMDatapnt.dat" For Input As #1Line Input #1, xyz 'Read file headerInput #1, Point.X, Point.Y, Point.Z xmin = Point.Xymin = Point.Yxmax = Point.Xymax = Point.Yinfolist.AddItem "Calculating min and max xy..." 'Loop to read every line of pointsWhile Not EOF(1)        Input #1, Point.X, Point.Y, Point.Z        If (xmin > Point.X) Then        xmin = Point.X    End If    If (ymin > Point.Y) Then        ymin = Point.Y    End If    If (xmax < Point.X) Then        xmax = Point.X    End If    If (ymax < Point.Y) Then        ymax = Point.Y    End If        npnt = npnt + 1     Wend

Read Input/Print To Output File
Hi...Can anyone help me....


I have a text file with names of player, number at bats, number of hits.
I do not know how to write the script to read in these data from the
text file and output them to an output file. I'm having trouble calculating
the total number at bats and total number of hits. Also, I don't know how to
to write the script to calculate the total average of bat and hits. Below is the input text file
that I have to read in. Also, I've attached a format of how the
output file look like. Please help...Thank you!

==================================
Kirk Bran
20
9
Robert Arne
15
5
Ian Brother
10
3
Ron Major
12
2
Don Treader
16
4
Randy Tins
7
1
Micheal Hunt
16
7
Tim Cody
8
2

How To Read Keyboard Input From Any Application (Solved)
Is it possible in VB to write some code that will activate when a key is pressed in any application on a PC. What I am after is some way of monitoring keyboard input and reacting to it even if the thread receiving keyboard input is not my VB application.

~ Shandy, Ex Microsoft VB MVP 2004/5 has a technical blog.
How To Get Your Questions Answered | Posting Guidelines | Search Facility | FAQs
Why not send Serge a postcard?

Edited by - Shandy on 3/10/2003 1:10:42 PM

Excel And Notepad: How Avoid Additional Inverted Commas After Copy And Paste?
Hi,
If I write a multi-line text in a cell (then go down with alt+enter) and after copy the cell pasting on Notepad, it display before inverted commas and after textual content.
Instead, if I select directly the content from the formula bar, it isn't happen.
Do exist a way for copy and paste directly from the cell without select from the formula bar?
Maybe with a macro?

Thank
Marco

__________________
nuove idee regalo compleanno, servizio realizzazione siti internet, forum scuole superiori, assistenza pantografo

Notepad To Access,Grid And Back To Notepad
Hi,
i hav a notepad where there are many lines stored in it.
i need it to separate it as each word(; as separtor).
actually there are 50 columns in Access as backend with various datatypes(49 for data and 1 for end of file........two boxes).
so after 50 countings are identified, it is considered as first record. and then data for second record starts.
after saving to the backend Access, i need to view the content in DataGrid(VB6) where editing of records is permitted.so after editing and while saving it to Access,i need the change to be reflected in Notepad also(with the same format as ; as separator between records and two boxes for end of record).
Plz help me to solve this...............its really urgent!!!

NOTE: Attached one.txt for sample and the backend Access table.

Read Text File Input#1 Comma Problems
Hello,

I'm using an plain ASCII file to read characters and send these right to the LPT1.

This is how I read the file:

Code:
Dim t As String

Open "LPT1:" For Output As #1
Open App.Path & "LABEL.txt" For Input As #2

Do Until EOF(2)
Input #2, t
Write #1, t
Debug.Print t
Loop

Close #1
Close #2

The problem is that the source file contains comma(,)s. Somehow this goes wrong. The comma is interpretated as an end of line?

This is the source file:
^XA
^LH30,30
^FO20,10^AD^FDZEBRA^FS
^FO20,60^B3^FDAAA001^FS
^XZ

This is the output:

Code:
'Debug results:
^XA
^LH30
30
^FO20
10^AD^FDZEBRA^FS
^FO20
60^B3^FDAAA001^FS
^XZ

Why are comma's changed to vbCR's? What can I do about it?

Thanks
Patrick

Read The Data From Input Text File In Crystal 9.0
Hi,

I am using Crystal 9.0.
I need to read the data from an Input file( data delimited by charecter '|' ) and do some processing and show the
data into a report.

I thought FileDSN is one appraoch to read the Input file.

Are there any other efficient ways of doing this task ?
Is there any way in Crystal we can just give the filename and its path ( Similar to Actuate Reports) and access the
records ?
Pls suggest.

Thanks,
Siva

Is It Poss In VB To Read Emails And Input Data (Resolved)
IS it possible in VB to read email and scan for specific values as input to a process within the program.

Improving An Input/read Text File Code
Hi there,

I have a function that opens a series of text files, one at a time. Each line in the text file is different in length and content.

The function checks each line for two words. If it finds them, it adds the user who said the words into two separate listboxes. At the end of the list, it saves the contents of the two listboxes into two text files, then proceeds to open the next text file and starts all over again.

This does work, but I am sure it is not very efficient. I would be interested in your thoughts/ideas on how this code could be improved.

Thanks for your help.



Code:
Private Sub Command1_Click()
Dim fso As New FileSystemObject
Dim thisfile As File
Dim allfiles As Files
Dim FileNum As Integer, item As String

Call clearlists
Path = ("C:Program FilesProgramSaved")
Set ofolder = fso.GetFolder(Path)
Set allfiles = ofolder.Files

For Each thisfile In allfiles
FileNum = FreeFile
Open thisfile For Input As FileNum
txtfile.Text = Right(thisfile, 13)

Do Until EOF(FileNum)
Line Input #FileNum, item
Form1.lstMain.AddItem item

If InStr(item, "hello") > 1 And Not CheckForHellos(item) Then
Form1.lstHello.AddItem Split(item, " ")(3), 0
End If

If InStr(item, "Goodbye") > 1 And Not CheckForGoodbyes(item) Then
Form1.lstGoodbye.AddItem Split(item, " ")(4)
End If
Loop
Close FileNum
Call SaveHellos
Call SaveGoodbyes
Call clearlists
Next
Form1.lstMain.AddItem "All lists saved and ready"
End Sub

Read Input Fields On WebPage From Visual Basic
If you are on a web page which has 6 fields for a user to enter data. The user hits a button which displays everything the user typed in the previous form. (Finished Product)

Once you are on this web page I want to run a Visual Basic program which will capture the users entered data. The user will click a button on my custom browser to start the program to capture the data.

Any ides on how to accomplish this one?



Edited by - cmc on 12/16/2003 7:17:06 AM

How To Read/write Encrypted File With Input/Output Functions?!
I wanna make my own filetype that only my program recognize, and cannot be editable in text editors like Notepad.



VB Code:
Private Const SIGNATURE = "Program Name"''''''Write''''Dim F As IntegerDim LineName As String, PointName As StringF = FreeFileOpen FileName For Output As #F   Write #F, SIGNATURE  Write #F, LineName  Write #F, Line.P1.X, Line.P1.Y, Line.P2.X, Line.P2.Y, LineColor  Write #F, PointName  Write #F, Point.X, Point.Y  .  .  .Close #F''''''Read''''Dim F As IntegerDim tmpStr As StringDim LineName As String, PointName As StringFF = FreeFileOpen FileName For Input As #F   Input #F, tmpStr      If tmpStr <> SIGNATURE Then        MsgBox "File format error!", vbCritical Or vbOKOnly        Close #F        Exit Sub      End If  Input #F, LineName  Input #F, Line.P1.X, Line.P1.Y, Line.P2.X, Line.P2.Y, LineColor  Input #F, PointName  Input #F, Point.X, Point.Y  .  .  .Close #F''''''''''  


Sorry for my pure English!
Any help will be appreciated.

Please,help Me~ I Need To Read Input Text File With Space-separated Datas In Lines
Hi, good day to all of you~

I'm a newbie in VB programming. Now I have to work out a project with this VB programming.

My question is that, how can I read an input text file with space-separated datas in every single lines in the .txt file?

eg. of input file:-
Bus Car Boat 1.0 2.0 3.0
1.2 1.3 2.2
521 544 566

As you can notice that there are no fixed of fields in the input file for each line. For example, there are 6 values in line #1, but 3 values for line #2 and line #3.

And one more thing is that the number of "space" between those values are not the same. There are 3 "spaces" between each values in the line #2.

I cannot change the input file by having only one "space" separated because the input file is in standard format.

Please... I really have no idea how to do this.

the following is my code:

VB Code:
Dim file_path As StringDim file_name As StringDim vin As String Private Sub Command1_Click()Dim hFile As IntegerDim strContents() As StringDim lngElement As Long ' Retrieve the contents of the file.Dim a, b, chFile = FreeFileOpen File1.Path + "" + File1 For Input As #hFileDo While Not EOF(hFile)ReDim Preserve strContents(0 To lngElement)Line Input #hFile, strContents(lngElement)lngElement = lngElement + 1LoopClose #hFile' Write the 1st line from the contents to Text1a = Split(strContents(0)) Me.Text1.Text = a(0)Me.Text2.Text = a(1)Me.Text3.Text = a(2)Me.Text4.Text = a(3)Me.Text5.Text = a(4)Me.Text6.Text = a(5) b = Split(strContents(1)) Me.Text7.Text = b(0)Me.Text8.Text = b(1)Me.Text9.Text = b(2) c = Split(strContents(2)) Me.Text10.Text = c(0)Me.Text11.Text = c(1)Me.Text12.Text = c(2)  End Sub  Private Sub Dir1_Change()    File1.Path = Dir1.PathEnd Sub Private Sub Drive1_Change()    Dir1.Path = Drive1.DriveEnd Sub Private Sub File1_Click()    File1.Path = Dir1.PathEnd Sub


The output when i read the input file:



p/s: do i have to make my code so complicated? any other way to simply it? Thanks~

How To Read An Excel Spreadsheet Column, That Is, Read From The Top Cell To Bottom Cell (like File R
How to read an excel spreadsheet column, that is, read from the top cell to bottom cell (like file read to eof)? how can I know which cell is the last cell?

thanks

Vb/Excel: How To Read An Excel File In A Column WITHOUT Specifying The Range ??
Hello, all.

I found a bit of code that lets me read an Excel file from and to a specifi
range. See the code below. But what if I only want to specify the STARTING
position and simply want it to continue reading down the column until it
hits an empty cell?

Does anyone know how to do this? Thanks!

Here is the range-only code:

' ** turn screen updating off, prevent the user from seeing the source
workbook
' ** then find the file and identify both the worksheet and range
Application.ScreenUpdating = False
Set sourcewb = Workbooks.Open(file, False, True)
listitems = sourcewb.Worksheets(sheet).range(temp_range).Value

' ** close the source workbook without saving changes, then reactive
screen update
sourcewb.Close False
Set sourcewb = Nothing
Application.ScreenUpdating = True

' ** read the data, convert values to a vertical array
listitems = Application.WorksheetFunction.Transpose(listitems)

For count = 1 To UBound(listitems)
' ** read the info into a temporary field
temp_var(count) = listitems(count) ' ** populate the array
Next count

' ** no items selected, set to 0 to select the first item
'Combo_machine.ListIndex = -1

Close Workbook

Can I Copy Excel File To Phase On Notepad Text File By Script??
Hello, I want to know that can I copy the excel file to notepad text file automatically????? By script,ok??

How To Read Excel Files From Excel Micro.
I need to write a micro in Excel to load data from Excel files. How I can do it
without open Excel file? Could you please give a example code?
Thanks in advance

Need Help With A String And Input From Excel
Sub eemail()
'
' email Macro
' Macro recorded 02/21/2002 by Steve Stokes
'
Dim WhoEmailIsTo As String
Dim expiringlocks As String

num_of_start = 7

ChDir ""
Workbooks.Open Filename:= _
"notimportant.xls"
Workbooks.Open Filename:= _
"notimportant.xls"
Windows("notimportant.xls").Activate

For i = 1 To 1
Range("C8").Select
ActiveCell.FormulaR1C1 = "='[notimportant.xls]Web Reqs'!R" & num_of_start & "C2"
Range("C9").Select
ActiveCell.FormulaR1C1 = "='[notimportant.xls]Web Reqs'!R" & num_of_start & "C5"
Range("C10").Select
ActiveCell.FormulaR1C1 = "='[notimportant.xls]Web Reqs'!R" & num_of_start & "C6"
Range("I11").Select
ActiveCell.FormulaR1C1 = "='[notimportant.xls]Web Reqs'!R" & num_of_start & "C11"
Range("A1").Select

WhoEmailIsTo = THIS IS WHERE I NEED THE HELP

expiringlocks = "this works set to a fixed text"

num_of_start = num_of_start + 1

Call mailit(WhoEmailIsTo, expiringlocks)

Next i

End Sub


Sub mailit(WhoEmailIsTo, expiringlocks)

Open "email.bat" For Output As #1

logfile = ">> email.log"
email = ".bat file use here, not imprtant"

Print #1, email

Close #1

Shell ("email.bat")

newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 6
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime

End Sub





this is what I am doing
I am writing this to do e-mails to a variable number of people, with variable e-mail addresses.
Where I put in red is where the end users email address variable goes, now I would like to know how I can set that to an excel spreadsheet cell formula
then use the counter (i know how to do this) to keep going down the list of cells for each email address
any help on this would be awesome

my basic question is how do I set a variable in VB equal to a number or string in a cell in excel?
thank you very much
-Steve

Excel And User Input
I have a command button on a spreadsheet.
this button copies values from a master sheet to where the user want it to go.
how can I prompt the user to select a cell with the mouse?
I will then copy the info to the active cell(the one the user clicked)

any ideas?
thank you for your time and have a good day

Excel Input And Output From VB
Due to lack of replies from the .Net forum I've decided to try here. I think this can be done using VB6 as well. How do you import 20 sequential cells from Excel 2002 into VB to perform some calculations using Excel functions (IRR, NPV, etc.) then insert the result back into the same worksheet and also to a label in VB?

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