Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Real beginner question

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I am new to VBscript and am writing a script to read in one file and write 2 other files based on a couple criteria.
For example: In the incoming file if field 3, positions 2,2 ="02" or "04" or "06" or "08" then write file1 else write file2. I have the code written to do all of this except I can't figure out how to easily make the determination as to which file it goes to. How do I code this to look in a particular position (its a particular position in the record since these files are fixed length ascii) for several different possibilities? I read the regexp and match objects/collections and didnot understand how to do this. At the end of this code I just need a variable that is equal to constant "file1" or constant "file2".
Please help.
Thanks
H
 
Do you mean something like:
Code:
strField3 = Mid(strRecord, ?, ?)
 :
 :
strTest = Mid(strField3, 2, 2) 
If strTest = "02" Or strTest = "04" Or _
   strTest = "06" Or strTest = "08" Then
      strFile = "file1"
Else
      strFile = "file2"
End If
 :
 :
And for more complex cases, use a Select Case statement. Or am I really missing something here?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top