Newbie Question on Variables


good day

I have a small program I'm attempting that passes on Variable to a switch needed by a .vbs script.

when the program runs it lists the name of the variable as opposed to the value the user types in.

the command line switch needed by the eventquery.vbs (a Microsoft script) requires the parameters to be in quotes. Of the 3 switches I use only one has a Variable I need to use for the Date.

Typing the exact syntax on the command line works, however using it from within VB with a user input box does not.

the command line to get the info I need is as follows

cscript eventquery.vbs \s servername /u domain\administrator /fi "Type eq error" /l system "type eq 6008" /fi "Datetime gt 01/01/06,01:01:00"

the part I get input from the user for is the Datetime. If I run this as above it works fine, if I make the Datetime property a user input variable for just the date part (not the time after the comma) the script returns the variable name and not the users input.

any guidance appreciated.

rich

carrollbluesfanAsked:
Who is Participating?
 
TimCotteeHead of Software ServicesCommented:
TimCottee,

Private Sub Command1_Click()
    Dim MyVariable As String
    MyVariable = InputBox("Enter a date", "Event Query", Format(Now, "dd/mm/yyyy"))
    Shell "cscript eventquery.vbs \s servername /u domain\administrator /fi ""Type eq error"" /l system ""type eq 6008"" /fi ""Datetime gt " & MyVariable & ",01:01:00AM"""
End Sub

Works fine for me (of course I don't have the script file) but there are no compilation problems and it generates the correct statement.


Tim
0
 
TimCotteeHead of Software ServicesCommented:
Hi carrollbluesfan,

MyVariable = InputBox (........)

Shell "cscript eventquery.vbs \s servername /u domain\administrator /fi ""Type eq error"" /l system ""type eq 6008"" /fi ""Datetime gt " & MyVariable & """"

Should do it.

Tim Cottee
0
 
carrollbluesfanAuthor Commented:

That's what I thought Tim, but the line shows red and gives me a compile error in VB. the Date format required by the VBS scripti is as below

/fi "Datetime gt 01/01/06,hh:mm:ssAM (or PM)

the ,hh:mm:ssAM is required. What I'm trying to do is give the admin the ability to enter a date into an input box and have the hh:mm:ssAM time stay always 01:01:00AM (anything after midnight the previous night.

from the command line the syntax works, but from the VB using just the one variable it doesn't...

rich

0
 
carrollbluesfanAuthor Commented:


I'll give yours a copy n paste and let you know....thanks for the quick responses.

rich

0
 
carrollbluesfanAuthor Commented:

Bullseye Tim.....thanks again for the quick responses.

rich
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.