I'm writing a scheduler for our application which pulls its tasks out of our central database. It runs a variety of things from external 'modules' of our application to custom SQL scripts.
I have declared as follows:
Dim ScheduleList As New DataTable
Dim WithEvents Actions As New Dictionary(Of String, String)()
Dim WithEvents Timers As New Dictionary(Of String, Timers.Timer)()
And my code that sets everything up is here.
Private Sub RunScheduleTasks()
Dim result() As DataRow = ScheduleList.Select("TriggerType = 0 AND IsEnabled = 1") 'External Calls
For Each row As DataRow In result
Dim i As Integer = row(0)
Actions.Add("action" + i.ToString, row(9).ToString)
WriteLog("Action Added: " + i.ToString, "INFORMATION")
Dim T As New System.Timers.Timer
With T
.Interval = Convert.ToInt32(row(7).ToString) * 1000
AddHandler T.Elapsed, Sub(sender, e)
Process.Start(row(9).ToString)
WriteLog(row(9).ToString, "INFORMATION")
End Sub
End With
Timers.Add("timer" + i.ToString, T)
WriteLog("Timer Added: " + i.ToString, "INFORMATION")
Timers("timer" + i.ToString).Start()
Next
WriteLog("Actions: " + Actions.Count.ToString, "INFORMATION")
WriteLog("Timers: " + Timers.Count.ToString, "INFORMATION")
End Sub
My Issue is that it only seems to run whatever the last created object was, My output logging shows several items in there however on inspecting them they all display Void _Lambda$__1()
Regards
Mike
Related
I am planning to create a project in the near future about quizzes and now I am practising some codes and this is my problem. I have a variable inside a private sub Button_Click. All variables work fine but I can't access it in other Private sub Button3_Click because it was a private variable so I decided it to make them a public variable.
Then when I ran it, it's only shows the last item on my database and I get back my original code and all the data in the database are shown and I create an event from my radiobutton when I checked it's automatically INSERT a data into my table. So I need the variable label but I can't access it in my event.
Note: All my controls are add programmatically when the database has a data except for panel1, button2 and button3.
This is my original code:
'This is for adding controls like labels and radiobutton dependeng in a number of data from database
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim conn As OleDbConnection = GetDBConnection()
Dim cmd As New OleDbCommand("SELECT * FROM tblEcobags ORDER BY N ASC", conn)
cmd.Prepare()
Dim dataReader As OleDbDataReader = cmd.ExecuteReader()
Do While dataReader.Read
Dim Cpanel As New Panel()
Dim count As Integer = Panel1.Controls.OfType(Of Panel)().ToList().Count
count = Panel1.Controls.OfType(Of Panel)().ToList().Count
Cpanel.Location = New Point(10, (25 * count) * 2.2)
Cpanel.Size = New Size(537, 51)
Cpanel.Name = "Cpanel" & (count + 1)
Cpanel.BackColor = Color.White
Panel1.Controls.Add(Cpanel)
Dim label As New Label()
count = Cpanel.Controls.OfType(Of Label)().ToList().Count
label.Location = New Point(10, (25 * count))
label.AutoSize = True
label.Name = "label_" & (count + 1)
label.Text = dataReader.Item("N") & "."
label.Font = New Font(label.Font.FontFamily, 10, FontStyle.Bold)
Cpanel.Controls.Add(label)
Dim lblQ As New Label()
count = Cpanel.Controls.OfType(Of TextBox)().ToList().Count
lblQ.Location = New System.Drawing.Point(40, 25 * count)
lblQ.AutoSize = True
lblQ.Name = "lblQ" & (count + 1)
lblQ.Text = dataReader.Item("ProductDes")
lblQ.Font = New Font(lblQ.Font.FontFamily, 11)
Cpanel.Controls.Add(lblQ)
Dim rbChoiceA As New RadioButton()
count = Cpanel.Controls.OfType(Of RadioButton)().ToList().Count
rbChoiceA.Location = New Point(40, 25)
rbChoiceA.AutoSize = True
rbChoiceA.Name = "rb" & (count + 1)
rbChoiceA.Text = dataReader.Item("Each")
rbChoiceA.Font = New Font(rbChoiceA.Font.FontFamily, 10)
AddHandler rbChoiceA.CheckedChanged, AddressOf rbChoiceA_Checked
Cpanel.Controls.Add(rbChoiceA)
Dim rbChoiceB As New RadioButton()
count = Cpanel.Controls.OfType(Of RadioButton)().ToList().Count
rbChoiceB.Location = New Point(200, 25)
rbChoiceB.AutoSize = True
rbChoiceB.Name = "rb" & (count + 1)
rbChoiceB.Text = dataReader.Item("PerDozen")
rbChoiceB.Font = New Font(rbChoiceB.Font.FontFamily, 10)
Cpanel.Controls.Add(rbChoiceB)
Loop
Button2.Enabled = False
conn.Dispose()
conn.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
'this is an event that i can't access my "label" that I add programmatically
Private Sub rbChoiceA_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim conn As OleDbConnection = GetDBConnection()
Dim cmd As New OleDbCommand("INSERT INTO tblSubmit(N)VALUES('" & must be label.text & "') ", conn)
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
You can set Variable as static in database or Text file or SQL or in program
like string myvar = "static";
Sorry for my bad description but I got it worked now. I used to declare it outside from any function but my mistakes that I made is declaring variable with parenthesis, I don't know the difference between that so I need to know the one without parenthesis works.
This is my modified declaration so It must be accessible to any function
Dim label as Label()
I got error on my updating code inside an event for my button2_Click
label = new label() ' I got error here
But when I removed the parenthesis on my declaration, it works.
Dim label as label
so may I ask what's the difference between that, why the one I used is no work than below that was worked. Thanks in advance for the respose.
I want to create a new button with the text displaying on another form for each item i have in the Globals.stringItems string array that I have populated via a .csv text file and displayed with a dataviewgrid.
Here is what I have:
Public Class Globals
Public Shared stringItems As String()
End Class
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(OpenFileDialog1.FileName)
MyReader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
MyReader.Delimiters = New String() {", "}
Dim currentRow As String()
'Loop through all of the fields in the file.
'If any lines are corrupt, report an error and continue parsing.
While Not MyReader.EndOfData
Try
currentRow = MyReader.ReadFields()
DataGridView1.Rows.Add(currentRow)
Globals.stringItems = currentRow
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox("Line " & ex.Message & " is invalid. Skipping")
End Try
End While
End Using
End If
Public Function AddNewButton() As System.Windows.Forms.Button
Dim button As New System.Windows.Forms.Button()
For Each item As String In Globals.stringItems
Me.Controls.Add(button)
button.Text = ?????????
Next
Return button
End Function
Am I even close? What am I missing? I can't seem to figure this out.
Since stringItems is declared as Public Shared it is globally accessed in all functions. so you need not to be specify like Globals.stringItems. and your AddNewButton() function is missing some logic.
I observed these from the snippet you have given;
You need to create no.of buttons which is equal to the number of items in the string array.
If so then you need not to use a Function. sub is enough.
For this scenario you can code like the following:
Public Sub AddNewButton()
Dim button As New System.Windows.Forms.Button()
Dim buttonTop As Integer = 100
For Each item As String In stringItems
Dim Location As New Point(100, (buttonTop + 20))
button.Location = Location
button.Text = item
button.Width=150
Me.Controls.Add(button)
buttonTop += 20
Next
End Function
If the stringItems contains 7 elements then it creates 7 buttons
We are using digital persona for our biometrics. We can already save employee ID, employee name and assigned finger .Our problem is that we dont know how to save a fingerprint template to a database and retrieve it so that it can still be read and verified by the biometric scanner. The file extension is ".ftp" .
CODE:
Private Sub buttonRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonRegister.Click
'Does user already exists
Dim bUserExists As Boolean = _Users.UserExists(New UserID(textBoxUserName.Text))
' first make sure the user is created if new user
If _ActiveUser Is Nothing Or Not bUserExists Then
' initialize with supplied user name
_ActiveUser = New User(textBoxUserName.Text)
Else
' update active user if not as originally selected
If bUserExists And Not listBoxUsers.SelectedItem.ToString() = textBoxUserName.Text Then
_ActiveUser = _Users(New UserID(textBoxUserName.Text))
End If
End If
' and check if the template already exists for the assigned finger
If _ActiveUser.TemplateExists(_AssignedFinger) Then
' show message indicating template already exists for selected finger
Dim diagResult As DialogResult = MessageBox.Show(Me, [String].Format("Oops!" + ControlChars.Cr + ControlChars.Lf + "{0} has a template enrolled to his/her {1} finger." + ControlChars.Cr + ControlChars.Lf + ControlChars.Cr + ControlChars.Lf + "Shall the old template be discarded?", _ActiveUser.ID.ToString(), _Fingers(_AssignedFinger)), "Template already assigned!", MessageBoxButtons.YesNo, MessageBoxIcon.Error)
' if user selected not to overwrite, then abort
If diagResult = Windows.Forms.DialogResult.No Then
Return
End If
End If
Try
' attempt to read the template
Dim templateOpened As New DPFP.Template(File.OpenRead(textBoxTemplateFilename.Text))
' run a template duplicate check
IdentifyTemplate(templateOpened)
' remove the old template if exists
If _ActiveUser.TemplateExists(_AssignedFinger) Then
' removed from assigned finger
_ActiveUser.RemoveTemplate(_AssignedFinger)
End If
' and assign it to the user as specified
_ActiveUser.AddTemplate(templateOpened, _AssignedFinger)
' update collection
If Not _Users.UserExists(_ActiveUser.ID) Then
' update list box
listBoxUsers.Items.Add(_ActiveUser.ID.ToString())
' add user it to the user collection
_Users.AddUser(_ActiveUser)
End If
' success
UpdateEventLog([String].Format("{0}: Template successfully assigned to {1} finger.", _ActiveUser.ID.ToString(), _AssignedFinger.ToString()))
' turn off groupbox
groupAddTemplate.Visible = False
listBoxUsers.SelectedItem = _ActiveUser.ID.ToString()
' sync gui
_syncUI()
' view user
_syncViewUser()
Catch Err As DPFP.Error.SDKException
' log message
UpdateEventLog(Err.ToString())
System.Diagnostics.Trace.WriteLine(Err.ToString())
Catch Err As System.IO.FileNotFoundException
' log message
UpdateEventLog("Template file not found or is inaccessible.")
System.Diagnostics.Trace.WriteLine(Err.ToString())
Catch Err As Exception
' log message
UpdateEventLog(Err.ToString())
System.Diagnostics.Trace.WriteLine(Err.ToString())
End Try
Using conn As New MySqlConnection("Server = localhost; Username= root; Password =; Database = vb")
Using cmd
With cmd
MsgBox("Connection Established")
.Connection = conn
.Parameters.Clear()
'Create Insert Query
.CommandText = "INSERT INTO employees(UserID, Name, Finger) VALUES (#iID, #iName, #iFinger)"
.Parameters.Add(New MySqlParameter("#iID", ID.Text))
.Parameters.Add(New MySqlParameter("#iName", textBoxUserName.Text))
.Parameters.Add(New MySqlParameter("#iFinger", comboBoxAssignedFinger.Text))
End With
Try
'Open Connection and Execute Query
conn.Open()
cmd.ExecuteNonQuery()
Catch ex As MySqlException
MsgBox(ex.Message.ToString())
End Try
End Using
End Using
i know that this is an old post but here are code blocks that might help...
IN SAVING I USED THIS
For Each template As DPFP.Template In Data.Templates
If Not template Is Nothing Then
cmd = New MySqlCommand("INSERT INTO employeefp " +
"SET No=#No, " +
"FP=#FP " +
" ", conn)
cmd.Parameters.Add(New MySqlParameter("#No", txtEmpNo.Text))
cmd.Parameters.Add(New MySqlParameter("#FP", template.Bytes))
cmd.ExecuteNonQuery()
End If
Next
IN VERIFYING FROM THE DB I USED THIS
WHEN FORM IS LOADED I FETCH ALL THE FINGER PRINTS
Dim cmd As New MySqlCommand("SELECT * FROM employeefp ", conn)
Dim rdr As MySqlDataReader = cmd.ExecuteReader()
While (rdr.Read())
Dim MemStream As IO.MemoryStream
Dim fpBytes As Byte()
fpBytes = rdr("FP")
MemStream = New IO.MemoryStream(fpBytes)
Dim templa8 As DPFP.Template = New DPFP.Template()
templa8.DeSerialize(MemStream)
Dim tmpObj As New AppData
tmpObj.No = rdr("No").ToString()
tmpObj.Template = templa8
FPList.Add(tmpObj)
End While
NOTE : Dim FPList As List(Of AppData) = New List(Of AppData) //you can find the definition of this in the SDK i just added Template (contains one print) aside from the existing Templates(contains many print)
COMPARE THE CURRENT SAMPLE FROM THE MACHINE
Sub OnComplete(ByVal Control As Object, ByVal FeatureSet As DPFP.FeatureSet, ByRef EventHandlerStatus As DPFP.Gui.EventHandlerStatus) Handles VerificationControl.OnComplete
Dim printFound As Boolean = False
VerifiedFPData = New AppData
Try
For Each FPData As AppData In FPList
Dim tmplateData As New DPFP.Template
tmplateData = FPData.Template
Dim compareTo As New DPFP.FeatureSet
compareTo = FeatureSet
Dim ver As New DPFP.Verification.Verification()
Dim res As New DPFP.Verification.Verification.Result()
If Not tmplateData Is Nothing Then
ver.Verify(FeatureSet, tmplateData, res)
If res.Verified Then
EventHandlerStatus = DPFP.Gui.EventHandlerStatus.Success
printFound = True
VerifiedFPData = FPData
Exit For ' success
End If
End If
Next
Catch ex As Exception
MessageBox.Show("verification error")
End Try
If printFound Then
//TO DO
Else
EventHandlerStatus = DPFP.Gui.EventHandlerStatus.Failure
// TODO
End If
End Sub
hope it helps someone :)
There are some missing codes from the answer above. The code of the class appdata is missing.These code is error without declaring first the tmpObj in the class AppData. Dim tmpObj As New AppData
tmpObj.No = rdr("No").ToString()
tmpObj.Template = templa8
FPList.Add(tmpObj)
I am working on a Windows forms project that connects to a Microsoft Access database, reads the the file, does some math and then provides some basic statistics back. Right now I am teaching myself VB and I know the code below could be more efficient. However, right now I am just trying to make it functional.
The program filters the data it needs via sql, and there are several sql statements. I separated the code for each of the sql statements and into a subroutine so that I could call each one when the form loads and also when the user clicks a button to update. The program works fine on the form load, however, when you click the update button you get the following error on the 'odaCalls.Fill' in subroutine Count(): "The select command property has not been initialized before calling 'Fill'.
Any help is greatly appreciated. I have searched on google and tried the suggestions found there but have not found a fix.
Option Explicit On
Public Class Form1
'Count() Variables
Dim strSQL = "SELECT * FROM tblcallLog"
Dim strPath As String = "Provider=Microsoft.ACE.OLEDB.12.0 ;" _
& "Data Source=C:\callLogRev2_be.accdb"
Dim odaCalls As New OleDb.OleDbDataAdapter(strSQL, strPath)
Dim datCallCount As New DataTable
Dim intCount As Integer = 0
'LiveCalls() variables
Dim strSQLLive As String = "SELECT * FROM tblcallLog WHERE callLive=True"
Dim odaCallsLive As New OleDb.OleDbDataAdapter(strSQLLive, strPath)
Dim datCallLive As New DataTable
Dim intCallLiveCount As Integer = 0
Dim decCallLivePct As Decimal
'TransferCalls() variables
Dim strSQLTransfered As String = _
"SELECT * FROM tblcallLog WHERE callName LIKE '% transfer %' OR callName LIKE 'transfer%'"
Dim odaCallsTransfered As New OleDb.OleDbDataAdapter(strSQLTransfered, strPath)
Dim datCallTransfered As New DataTable
Dim intCallTransfered As Integer = 0
Dim decCallTranfered As Decimal
'SingleStaffCall() Variables
Dim strSQLSingleStaff As String = _
"SELECT * FROM tblcallLog WHERE callName LIKE '% single %' OR callName LIKE 'single%'"
Dim odaCallSingleStaff As New OleDb.OleDbDataAdapter(strSQLSingleStaff, strPath)
Dim datCallSingleStaff As New DataTable
Dim intCallSingleStaff As Integer = 0
Dim decCallSingleStaff As Decimal
'SingleStaffCallsLive() Variables
Dim strSQLSingleStaffLive As String = _
"SELECT * FROM tblcallLog WHERE callName LIKE '% single %' OR callName LIKE 'single%' AND callLive=True"
Dim odaCallSingleStaffLive As New OleDb.OleDbDataAdapter(strSQLSingleStaffLive, strPath)
Dim datCallSingleStaffLive As New DataTable
Dim intCallSingleStaffLive As Integer = 0
Dim decCallSingleStaffLive As Decimal
'CallToday() Variables
Dim strSQLToday As String = _
"SELECT * FROM tblcallLog WHERE startDate = date()"
Dim odaCallToday As New OleDb.OleDbDataAdapter(strSQLToday, strPath)
Dim datCallToday As New DataTable
Dim intCallToday As New Integer
'CallTodayLive() Variables
Dim strSQLTodayLiveCalls As String = _
"SELECT * FROM tblcallLog WHERE callLive=TRUE AND startDate = date()"
Dim odaCallTodayLive As New OleDb.OleDbDataAdapter(strSQLTodayLiveCalls, strPath)
Dim datCallTodayLive As New DataTable
Dim intCallTodayLive As New Integer
Dim decCallTodayLive As New Decimal
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Count()
LiveCalls()
TransferCalls()
SingleStaffCalls()
SingleStaffCallsLive()
CallToday()
CallTodayLive()
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
'Checks the database for updates when user pushes the update button on the static data tab.
Count()
LiveCalls()
TransferCalls()
SingleStaffCalls()
SingleStaffCallsLive()
CallToday()
CallTodayLive()
End Sub
Private Sub Count()
'database connect and call count
odaCalls.Fill(datCallCount)
odaCalls.Dispose()
intCount = datCallCount.Rows.Count
lblTotalCallsData.Text = intCount.ToString
lblTotalCallsData.Visible = True
End Sub
Private Sub LiveCalls()
'determine number of live calls
odaCallsLive.Fill(datCallLive)
odaCallsLive.Dispose()
intCallLiveCount = datCallLive.Rows.Count
lblcallsLiveData.Text = intCallLiveCount.ToString
lblcallsLiveData.Visible = True
decCallLivePct = intCallLiveCount / intCount
lblPctCallsLiveData.Text = decCallLivePct.ToString("P")
lblPctCallsLiveData.Visible = True
End Sub
Private Sub TransferCalls()
'determine the number of transfer calls
odaCallsTransfered.Fill(datCallTransfered)
odaCallsTransfered.Dispose()
intCallTransfered = datCallTransfered.Rows.Count
lblTotalTransferCallsData.Text = intCallTransfered.ToString
lblTotalTransferCallsData.Visible = True
decCallTranfered = intCallTransfered / intCount
lblPctTransferCallsData.Text = decCallTranfered.ToString("P")
lblPctTransferCallsData.Visible = True
End Sub
Private Sub SingleStaffCalls()
'determine the number of single staff calls and percentage of total
odaCallSingleStaff.Fill(datCallSingleStaff)
odaCallSingleStaff.Dispose()
intCallSingleStaff = datCallSingleStaff.Rows.Count
lblTotalSingleStaffCallData.Text = intCallSingleStaff.ToString
lblTotalSingleStaffCallData.Visible = True
decCallSingleStaff = intCallSingleStaff / intCount
lblPctSingleStaffCallsData.Text = decCallSingleStaff.ToString("P")
End Sub
Private Sub SingleStaffCallsLive()
'determine the percentage of single staff calls taken live
odaCallSingleStaffLive.Fill(datCallSingleStaffLive)
odaCallSingleStaffLive.Dispose()
intCallSingleStaffLive = datCallSingleStaffLive.Rows.Count
decCallSingleStaffLive = intCallSingleStaffLive / intCount
lblPctSingleStaffCallsLiveData.Visible = True
lblPctSingleStaffCallsLiveData.Text = decCallSingleStaffLive.ToString("P")
End Sub
Private Sub CallToday()
'determine values for todays date
odaCallToday.Fill(datCallToday)
odaCallToday.Dispose()
intCallToday = datCallToday.Rows.Count
lblTotalCallsTodayData.Text = intCallToday
lblTotalCallsTodayData.Visible = True
End Sub
Private Sub CallTodayLive()
'determine the number of live calls today
odaCallTodayLive.Fill(datCallTodayLive)
odaCallTodayLive.Dispose()
intCallTodayLive = datCallTodayLive.Rows.Count
lblCallsTodayLiveData.Text = intCallTodayLive.ToString
lblCallsTodayLiveData.Visible = True
'Statement to error correct so the database doesn't force the program to divide by zero
Try
decCallTodayLive = intCallTodayLive / intCallToday
Catch Exception As DivideByZeroException
lblPctCallsTodayLiveData.Text = "0.00%"
lblPctCallsTodayLiveData.Visible = True
Catch Exception As OverflowException
decCallTodayLive = 0
End Try
lblPctCallsTodayLiveData.Text = decCallTodayLive.ToString("P")
lblPctCallsTodayLiveData.Visible = True
End Sub
End Class
The problem is that you are disposing the dataadapters immediately after filling them.
This is why it works on form load, but not after. It would be better practice to create the and destroy the dataadapters in the methods where they are used instead of creating them on spec at the form level.
I am new to VB and I am trying to add text from a thread to a listview in my Form1.
I have tried implementing the invokerequired method but still the new text is not added to my listview.
(please see function addlvDataItem)
This what I call in my thread class:
Private Sub DoServerListening()
'Thread to listen for new incoming socket clients
Dim mSocket As System.Net.Sockets.Socket
Dim newConnectionThread As clsTCPConnection
Dim strRemoteIPAddress As String
Do
Try
While bServerRunning = True
If mTCPListener.Pending = True Then
mSocket = mTCPListener.AcceptSocket()
'mSocket.Blocking = True
If mSocket.Connected Then
strRemoteIPAddress = Split(mSocket.RemoteEndPoint.ToString, ":")(0)
newConnectionThread = New clsTCPConnection(mSocket, strRemoteIPAddress)
'Start the thread to handle this connection
Form1.addlvDataItem("Connected to " & strRemoteIPAddress.ToString(), 0)
Dim myThread As New System.Threading.Thread(AddressOf newConnectionThread.HandleConnection)
myThread.Start()
End If
End If
End While
Catch ex As Exception
If bServerRunning = True Then
'notify main application
End If
End Try
Loop
End Sub
and this is what i do in my Form1 class
Public Delegate Sub addlvDataItemCallback(ByVal [text] As String, ByVal Num As Integer)
Public Sub addlvDataItem(ByVal [text] As String, ByVal Type As Integer)
CurrentDateTime = DateTime.Now
If lvData.InvokeRequired Then
Dim d As New addlvDataItemCallback(AddressOf addlvDataItem)
Me.Invoke(d, New Object() {[text]})
Else
If Type = 1 Then 'TX
Me.lvData.Items.Add("TX (" + text.Length.ToString() + " bytes): " + CurrentDateTime + " : <Start> " + text.ToString() + "<End>")
ElseIf Type = 2 Then
Me.lvData.Items.Add("RX (" + text.Length.ToString() + " bytes): " + CurrentDateTime + " : <Start> " + text.ToString() + "<End>")
Else
Me.lvData.Items.Add("Info: " + CurrentDateTime + " : " + text.ToString())
End If
End If
End Sub
The new text that I add is not displayed in the listview. I do not get any compile or runtime errors but still no new text to list box. I can add text from my Form1 class but not from the thread.
You provided code does throw an TargetParameterCountException.
You have to pass all parameters to your delegate sub:
Me.Invoke(d, New Object() {[text], Type})
instead of
Me.Invoke(d, New Object() {[text]})