Link to home
Start Free TrialLog in
Avatar of Nate
NateFlag for United States of America

asked on

VB Code question

Please forgive me for asking simple questions, I am just getting into programming VB...

I am trying to create a VB program but I am having a tremendous amount of difficulty with it. I keep getting 'Backgroundworker1' is not a member of System.EventArgs

I have searched and nothing I find it helpful to me.

If anyone needs me to attach a zip file containing the source, I can but this is the code I'm using...

Public Class Form1

    Dim sys_running As Integer

    Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        If sys_running = 0 Then
            sys_running = 1
            StartBtn.Text = "Stop"
        ElseIf sys_running = 1 Then
            sys_running = 0
            StartBtn.Text = "Start"
        End If
        Do Until sys_running = 0
            If Keep_Alive.Checked = True Then
                keepalive()
            End If
            If Log_Check.Checked = True Then
                'do something here
            End If
            If Kick_Stop.Checked = True Then
                'Kick Stop
            End If
            If Auto_SS.Checked = True Then
                'Auto-Start/Stop
            End If
        Loop

    End Sub

    Private Sub StartBtn_Click(ByVal sender As Object, ByVal e As EventArgs) Handles StartBtn.Click
        e.BackgroundWorker1.runworkasync()
    End Sub
    Private Sub keepalive()

    End Sub
End Class

Open in new window

Avatar of Bill Prew
Bill Prew

You marked this as VBSCRIPT, but it looks more like VB.net or VBA.  What environment are you working with?

~bp
Avatar of Nate

ASKER

That's how new I am, I do not know which... I thought VB was VB....

I am using Visual Studio 2013

When I start "New Project" it says "Visual Basic" and then "Windows Forms Application" with a little "VB" on it.
Avatar of Nate

ASKER

Thank you for your assistance...
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are using Visual Studio, you are using VB.NET. Although it uses the same syntax, this is different from VB6, VBA or VBScript.

Remove the e. in front of e.BackgroundWorker1.

e is a parameter passed to the event. It is useful in some event to get information and pass back information to the system. but is useless in a Click event.

Assuming that your BackgroundWorker is in the same Form as the Button that triggers the Click, simply call you BackgroundWorker without any prefix.

And if I were you, because you are just beginning, I would try to work with simpler objects. The BackgroundWorker is not an easy object to work with.
have a look at my article on the BackgroundWorker component: http://emoreau.com/Entries/Articles/2006/12/The-BackgroundWorker-component.aspx
Avatar of Nate

ASKER

Everything I've seen online tells me to use e.backgroundworker, thank you.
>>Everything I've seen online tells me to use e.backgroundworker

Maybe it was responding to a different event.