I need to build an application that receive a parĂ¡meter like a option that return data. How i declare this parameter in the first form or module and the variable returned ?
Printable View
I need to build an application that receive a parĂ¡meter like a option that return data. How i declare this parameter in the first form or module and the variable returned ?
Can not get what you mean.
Explain your problem, and I may be able to help you.
If you mean you want to save a setting when you finish with the programme, and retrieve it later, you can use the commands GetSetting and SaveSetting. These use the registry to save any setting you want and retrieve it later.
Say you have a text box called Text1, and you want it to 'remember' what it said the last time the user ran the programme, you would put in the Form_Unload event
and in the Form_Load event,Code:SaveSetting("MyApp","Startup","Text",Text1.text)
Code:Text1.text=GetSetting("MyApp","Startup","Text","")
Excuse my poor description of problem.
I want to build an application that receive data from command line and return data to command line, i.e.
"myapp.exe parameter", and return code of execution (success or no).
To retrieve data from the command line, you use the Command$ operator in the form_load event.
I don't know how to return data to the command-line.Code:Msgbox "You said " & Command$
You should get the command line paramter when your program is started and not at the mid way of your program.
or if your program is start from a Sub main module.Code:'Declare under Basic Module File
Option Explicit
Public MyCommandLine As String
Private Sub Form_Load()
MyCommandLine = Command()
'Assume your program will only loaded when the command line string is /%2
If MyCommandLine <> "/%2" then End
End Sub
Code:Option Explicit
Public MyCommandLine As String
Public Sub Main ()
MyCommandLine = Command()
'Assume your program will only loaded when the command line string is /%2
If MyCommandLine <> "/%2" then
End
Else
Load frmMain
frmMain.Show
End If
End Sub
Retrieving parameters from the commandline has been answered already.
I don't think you can return a value from a VB prog other than putting some file on disk or write a value to the registry.
If I'm wrong I would like to know, cause I've always considered this an omission in VB.