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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asc(x) not working 1

Status
Not open for further replies.

barny2006

MIS
Mar 30, 2006
521
US
i have 2 vb scripts. both have this command asc(x) which is ascii value of a character, x. one works, the other one doesn't and give an error message that "invalid procedure call or argument".
any body has any idea why this is?
 
here's the code. basically what it does, is that it puts the results of the "dir" in a text file, and then reads the text file and lists each line that has a file listed. so staff could start uploading the files into the database.

'==========================================================
dim fs, objTextFile, msg, info, info2, title, icon, wshshell, xxx, zzz
dim eachline, arrStr, struser, strfullname
Set wshshell = WScript.CreateObject("WScript.Shell")

title = "STELLAR files waiting to be uploaded"
icon=vbinformation

set fs=CreateObject("Scripting.FileSystemObject")

wshshell.Run("cmd.exe /c dir s:\research\stellar3\maindata\import\54000*.* > c:\a_pictures\steldata.txt")
'let the file get finished writing and settled.
wScript.sleep 300

set objTextFile = fs.OpenTextFile("c:\a_pictures\steldata.txt")

info = date() & "-" & time() & vbcrlf & vpcrlf
info2 = "No files are waiting for upload to Stellar" & vbcrlf
Do while NOT objTextFile.AtEndOfStream

eachline = objTextFile.ReadLine
zzz=left(eachline,1)
if left(eachline,1) <> " " then
msg = msg & eachline & vbcrlf

xxx = asc(zzz)
info2 = "The following files are waiting to be uploaded to Stellar" & vbcrlf

end if
Loop

msgbox info & info2 & msg, vbokonly, title

objTextFile.Close
set objTextFile = Nothing
set fs = Nothing
 
documentation said:
Asc Function
Returns the ANSI character code corresponding to the first letter in a string.
Asc(string)
The string argument is any valid string expression. [red]If the string contains no characters, a run-time error occurs.[/red]
Your script.
>[tt]if left(eachline,1) <> "[COLOR=white red] [/color]" then [/tt]
[tt]if left(eachline,1) <> "" then[/tt]

 
:)
thanks tsuji.
i tried it and it worked with "" instead of " ". great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top