Argument not specified

C

CrashGirl

Anybody have an idea on what i am doing wrong here,

CheckSetService - Argument not specified for parameter 'Tipo' of
'Private Sub CheckSetService(Tipo As Long)'.

Private Sub btnStartService_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnStartService.Click
CheckSetService(1)
End Sub

Private Sub btnStopService_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnStopService.Click
CheckSetService(2)
 
C

CrashGirl

Hi,

I tried but not worked... :( and I have other problem... with this
"object reference not set to an instance of an object" anyone knows
what´s the problem?

(e-mail address removed) escreveu:
 
T

tommaso.gastaldi

yes, CG that is the generic message you get when trying to use an
object which you have not instantiated yet. You will see it some
million times in your life if you keep programming... :) although the
new IDE try to warn when possible

Post the code, otherwise nobody is able to help you ...

-t

CrashGirl ha scritto:
 
C

Cor Ligthert [MVP]

CrashGirl

As you show us code, than please show it at least well.
'Private Sub CheckSetService(Tipo As Long)'.

Are you sure that this is exactly as this in your code?

Cor
 
C

CrashGirl

hi Guys, here is my code...

Private Sub btnStartService_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnStartService.Click
CheckSetService(1)
End Sub

Private Sub btnStopService_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnStopService.Click
CheckSetService(2)
End Sub

Private Sub CheckSetService(ByVal Tipo As Long)
Dim Svc As ServiceProcess.ServiceController
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
Svc = New ServiceProcess.ServiceController
Svc.ServiceName = "SWFTPClient"
Svc.Refresh()
Select Case Tipo
Case 1
Try
If
Svc.Status.Equals(ServiceProcess.ServiceControllerStatus.Stopped) Then
Me.sBar.Text = "Iniciando o serviço !
Aguarde..."
Svc.Start()
Svc.Refresh()
End If
Catch ex As Exception
End Try
Case 2
Try
If
Svc.Status.Equals(ServiceProcess.ServiceControllerStatus.Running) Then
Me.sBar.Text = "Parando o serviço !
Aguarde..."
Svc.Stop()
Svc.Refresh()
End If
Catch ex As Exception
End Try
End Select
Try
Select Case Tipo
Case 1

Svc.WaitForStatus(ServiceProcess.ServiceControllerStatus.Running,
System.TimeSpan.FromSeconds(30))
Case 2

Svc.WaitForStatus(ServiceProcess.ServiceControllerStatus.Stopped,
System.TimeSpan.FromSeconds(30))
End Select
Catch ex As Exception
Svc.Refresh()
End Try
Try
Me.lblStatusSvc.Text = "SWFTPClient Service: " &
Svc.Status.ToString
If
Svc.Status.Equals(ServiceProcess.ServiceControllerStatus.Stopped) Then
Me.btnStartService.Enabled = True
Me.btnStopService.Enabled = False
ElseIf
Svc.Status.Equals(ServiceProcess.ServiceControllerStatus.Running) Then
Me.btnStartService.Enabled = False
Me.btnStopService.Enabled = True
End If
Catch ex As Exception
Me.lblStatusSvc.Text = "SWFTPClient Service: Indisponível"
Me.btnStartService.Enabled = False
Me.btnStopService.Enabled = False
End Try
Me.sBar.Text = ""
Me.Cursor = System.Windows.Forms.Cursors.Default

When I click button start to service my file log register ("Object
reference
not set to an instance of an object")
Only when i start my service...
 
C

Cor Ligthert [MVP]

CrashGirl,

I see 4 times Tipo, where is it giving the error?
(Although I do not see the sense why it is long while integer is the most
sufficient numeric value or here even Boolean can be used).

Cor

"CrashGirl" <[email protected]> schreef in bericht
hi Guys, here is my code...

Private Sub btnStartService_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles btnStartService.Click
CheckSetService(1)
End Sub

Private Sub btnStopService_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnStopService.Click
CheckSetService(2)
End Sub

Private Sub CheckSetService(ByVal Tipo As Long)
Dim Svc As ServiceProcess.ServiceController
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
Svc = New ServiceProcess.ServiceController
Svc.ServiceName = "SWFTPClient"
Svc.Refresh()
Select Case Tipo
Case 1
Try
If
Svc.Status.Equals(ServiceProcess.ServiceControllerStatus.Stopped) Then
Me.sBar.Text = "Iniciando o serviço !
Aguarde..."
Svc.Start()
Svc.Refresh()
End If
Catch ex As Exception
End Try
Case 2
Try
If
Svc.Status.Equals(ServiceProcess.ServiceControllerStatus.Running) Then
Me.sBar.Text = "Parando o serviço !
Aguarde..."
Svc.Stop()
Svc.Refresh()
End If
Catch ex As Exception
End Try
End Select
Try
Select Case Tipo
Case 1

Svc.WaitForStatus(ServiceProcess.ServiceControllerStatus.Running,
System.TimeSpan.FromSeconds(30))
Case 2

Svc.WaitForStatus(ServiceProcess.ServiceControllerStatus.Stopped,
System.TimeSpan.FromSeconds(30))
End Select
Catch ex As Exception
Svc.Refresh()
End Try
Try
Me.lblStatusSvc.Text = "SWFTPClient Service: " &
Svc.Status.ToString
If
Svc.Status.Equals(ServiceProcess.ServiceControllerStatus.Stopped) Then
Me.btnStartService.Enabled = True
Me.btnStopService.Enabled = False
ElseIf
Svc.Status.Equals(ServiceProcess.ServiceControllerStatus.Running) Then
Me.btnStartService.Enabled = False
Me.btnStopService.Enabled = True
End If
Catch ex As Exception
Me.lblStatusSvc.Text = "SWFTPClient Service: Indisponível"
Me.btnStartService.Enabled = False
Me.btnStopService.Enabled = False
End Try
Me.sBar.Text = ""
Me.Cursor = System.Windows.Forms.Cursors.Default

When I click button start to service my file log register ("Object
reference
not set to an instance of an object")
Only when i start my service...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top