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

Pass Parameters Thru Shell command

Status
Not open for further replies.

bzac

Programmer
Dec 20, 2000
55
0
0
US
Dim Retval
Retval = Shell(" c:\SCADA\scadapgm.exe '02OX0468920105' '24 SEP 99 12:00:00 p.m.' 25", 6)

The above command is working perfectly.

Here the 1st portion is the program to be executed, 2nd part is the customer id, and the 3rd part is date, and last part is no. of hours.


The ID is selecting from 'MSHFlexgrid', the the date part is getting from a 'datetimepicker control', and the No.of Hours is from a 'text box'.

The main problem is I don't know how to format Date in that format in VB.

Anybody please help me to solve this.

Thank you
 
I got the Idea & it is working..

::::::::::::::
Dim SelID As String
SelID = lblCId.Caption
AEDt = DtpEndDate.Value
Dim nhrs As Integer
nhrs = CInt(txthours.Text)
'format date for Scadapgm
Dim SelDate As Date
SelDate = FormatDateTime(AEDt, vbGeneralDate)
Dim SelMth As String, SelDay As Integer, SelYY As Integer
SelMth = Left(MonthName(Month(AEDt)), 3)
SelDay = Day(AEDt)
SelYY = Mid(Year(AEDt), 2, 2)
'create string to run Scadapgm.exe
Dim strScada As StringDim strQuotes As String
strQuotes = """"
strScada = ("C:\SCADA\SCADAPGM.EXE" & " " & strQuotes & SelID & strQuotes & " " & strQuotes & SelDay & " " & SelMth & " " & SelYY & " " & "12:00:00 p.m." & strQuotes & " " & nhrs)
'Run scadapgm.exe
Dim Retval
Retval = Shell(strScada, 6)
If Retval = 0 Then
MsgBox "cannot Run SCADAPGM, Retry later!!"
Exit Sub
End If
:::::::::
 
Use the Format function to format AEDt to the required format, then you do not have to use the individual parts.

(Also, if you want to do it this way, you can also use the format function to get just the day number, month number and year number more easily than you have done -

SelMth = Format(AEDt,"mmm")
SelDay = Format(AEDt,"dd")
SelYY = Format(AEDt,"yy") ' or SelYY = Format(AEDt,"yyyy") for 4 digit year

If you use:

Format(AEDt,"dd mmm yy") & " 12:00:00 p.m."

in your shell line where you want the date to go, then you do not need these lines:

SelDate = FormatDateTime(AEDt, vbGeneralDate)
Dim SelMth As String, SelDay As Integer, SelYY As Integer
SelMth = Left(MonthName(Month(AEDt)), 3)
SelDay = Day(AEDt)
SelYY = Mid(Year(AEDt), 2, 2)
Simon
 
Thank You very much Simon, I will use it that way.

Will you please look at my thread on "MSHFlex grid Row Selection", please it is creating problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top