Open a web link in windows form (Vb.Net)
I want to open a web page that was created by me, by passing parameters to that web link, I try to open it like this:
Dim aaa As String = String.Format _
("C:\Documents and Settings\user\Desktop\web site 1\HRMSExport1.aspx", _
"?_mchno={0}&_batch={1}&_Points={2}&_ovrpt={3}&_gstrID={4}& _
_gstrPassword={5}&_gstrDataSource={6}&_gstrCatalo开发者_StackOverflow中文版g={7}", _
cmbMachine.Text, txtBatch.Text, inpstd, _
Overpoints, gstrID, gstrPassword, gstrDataSource, gstrCatalog)
Process.Start(aaa)
but it fails. How to open a web link with parameters??
Your String.Format command and line breaks are incorrect. On line 2, replace the comma with an ampersand. On line 3, you cannot use a line continuation inside a String. Close the string, use the line continuation, then add the rest of the string.
Try:
Dim commandline As String = String.Format _
("C:\Documents and Settings\user\Desktop\web site 1\HRMSExport1.aspx" & _
"?_mchno={0}&_batch={1}&_Points={2}&_ovrpt={3}&_gstrID={4}&" & _
"_gstrPassword={5}&_gstrDataSource={6}&_gstrCatalog={7}", _
_cmbMachine.Text, txtBatch.Text, inpstd, Overpoints, gstrID, _
gstrPassword, gstrDataSource, gstrCatalog)
Process.Start(commandline)
It looks like you have two format strings being passed to your string.format
Try this:
Dim aaa As String = String.Format _
("C:\Documents and Settings\user\Desktop\web site 1\HRMSExport1.aspx?_mchno={0}&_batch={1}&_Points={2}&_ovrpt={3}&_gstrID={4}&_gstrPassword={5}&_gstrDataSource={6}&_gstrCatalog={7}", _
cmbMachine.Text, txtBatch.Text, inpstd, Overpoints, gstrID, gstrPassword, gstrDataSource, gstrCatalog)
Process.Start(aaa)
精彩评论