-
Feb 21st, 2011, 07:54 PM
#1
Thread Starter
New Member
[RESOLVED] Argument not specified for parameter
I'm making a console application, but I get the error shown below and I don't understand the problem.
I will be passing command-line arguments like this:
prog.exe 192.168.0.1 80 On
Code:
Imports System
Imports System.Text
Imports System.Net.Sockets
Module Module1
Public Sub Main()
Dim arguments As [String]() = Environment.GetCommandLineArgs()
Dim ip As String
Dim port As String
ip = Environment.GetCommandLineArgs(1)
port = Environment.GetCommandLineArgs(2)
If Environment.GetCommandLineArgs(3) = "On" Then
sendRequest("ip, port, 1") <--- underlined and says "Argument not specified for parameter 'port' of 'Private Sub sendRequest(ip As String, port As Integer, val as String)
End If
If Environment.GetCommandLineArgs(3) = "Off" Then
sendRequest("ip, port, 0") <--- underline here too
End If
End Sub
Private Sub sendRequest(ByVal ip As String, ByVal port As Integer, ByVal val As String)
Dim tcpClient As New System.Net.Sockets.TcpClient()
Try
'Connect to device
tcpClient.Connect(ip, port)
If tcpClient.Connected Then ...
Can someone point out where I went wrong?
-
Feb 21st, 2011, 08:13 PM
#2
Thread Starter
New Member
Re: Argument not specified for parameter
Sorry, I'm new, I think it's relevant that I'm using VB 2010
-
Feb 21st, 2011, 09:00 PM
#3
Re: Argument not specified for parameter
In this code:
vb.net Code:
sendRequest("ip, port, 1")
you have created a literal String containing the text "ip, port, 1" and you're passing that as an argument. What you actually need to do is pass those three separate values as arguments:
vb.net Code:
sendRequest(ip, port, "1")
That passes three arguments, i.e. the value of the 'ip' variable, the value of the 'port' variable and the literal string "1".
-
Feb 22nd, 2011, 12:39 PM
#4
Thread Starter
New Member
Re: Argument not specified for parameter
Thank you jmcilhinney, works perfectly!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|