Why dont the Command Button excecute the form - vb.net-2010

Good day. I Created a form that worked perfectlt, after testing the Command Button a few times and entering information into the form I decided to straiten out the form and make it tidy. after saving the form i tried to click the Command butten but this time it gave me a Error 424. Object Required.
(I tried to upload pictures with no success)
When I Check the Debug it highlight the .show command.
Private Sub CommandButton1_Click()
ClaimUserForm.Show
End Sub
I also tried:
Private Sub CommandButton1_Click()
Dim Claim as ClaimUserForm
Set Claim = new ClaimUser
claim.show
End Sub
But the debug re-appear.
in the form property window the form name is ClaimUserForm
Please help, I cant understand why it suddenly gave this problem.
Thanks

Is your button working properly? It seems it's missing the sender-object and the events.
Also set is not necessary.
Private Sub CommandButton1_Click(sender As Object, e As EventArgs) Handles CommandButton1.Click
Dim Claim As ClaimUserForm = New ClaimUser
Claim.Show
End Sub
sender As Object, e As EventArgs and Handles Button1.Click are missing.

Related

How to detect changes to a bound data

Winforms App - VB.Net 4.6.1
I have a data table that I fill when my form loads as follows:
Private Sub OnFormLoad(sender As Object, e As EventArgs) Handles MyBase.Load
Me.ApGetMratesListTableAdapter.Fill(Me.DsMRatesList.apGetMratesList)
End Sub
On the form I have textbox bound (Me.ApGetMratesListBindingSource) to a field in this datatable . I want to catch some sort of "RowChanged" event when the value in the textbox changes so I can set a "dirty" flag. Unfortunately after an hour of Googling and reading page after page with no examples of how to write the method I'm asking for help. Basically I cannot figure out how to refer to the event i.e. the part after HANDLES.
Private Sub SetDirty(ByVal sender As System.Object,
ByVal e As DataRowChangeEventArgs) Handles ?
m_IsDirty = True
End Sub
I've experimented until I ran out of options. If anyone can clue me as to how to write the event for the above Sub I'd be very grateful. If the signature isn't correct please clue me on that as well. Thank you!

vb.net masked textbox and datetime now string not working together?

I have a masked textbox set to date.short I would like to automate the cuurentdate to be filled in when the masked textbox is clicked I though the following would work but I get the error InvalidCastExpectation was ungandeld "Application is in break mode"
Private Sub MaskedTextBox1_Click(sender As Object, e As MaskInputRejectedEventArgs) Handles MaskedTextBox1.Click
MaskedTextBox1.Text = DateTime.Now.ToString("dd/MM/yyyy")
End Sub
I also thought about changing ("dd/MM/yyyy") to ("dd-MM-yyyy") but this also dosnt fix it?
The Click event does not use the MaskInputRejectedEventArgs parameter:
Private Sub MaskedTextBox1_Click(sender As Object, e As EventArgs)
Handles MaskedTextBox1.Click

Launching hyperlink from DataGridViewLinkCell

I'm loading a DataSet into a DataGridView. The data is a hyperlink to a file on the local network but I can't get the link to actually launch the file. Do I have to go into the clickevent and actually launch it from there? Or is there a property I can set on the DataGridViewLinkCell to do it without the fuss?
Thanks, code is below.
'dgMain is the DataGridView
dgMain.DataSource = dataSet1.Tables(0)
'Just an example, will format entire column when I'm done
dgMain(10, 1) = New DataGridViewLinkCell
If I did go clickevent route I think it would be something like this but it doesn't work very well but I haven't tried much yet:
Private Sub dgMain_CellContentClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgMain.CellContentClick
If e.RowIndex = -1 Then
Exit Sub
End If
If dgMain.Rows(e.RowIndex).Cells(e.ColumnIndex) Is DataGridViewLinkCell Then
Process.Start(dgMain.Rows(e.RowIndex).Cells(e.ColumnIndex).ToString)
End If
End Sub
Yes you need to handle the click event and launch the URL in code (Process.Start)

Filling in email and password using a button on Microsoft login \w out API

I have been struggling to figure out on how to fill in the email and password on the page and click a button to log into Microsoft, but I cant figure it out. I am very new to VB.net and would like some help to get better at and to learn. so far I have:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("https://login.live.com/")
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim elements = WebBrowser1.Document.GetElementsByTagName("input")
For Each element As HtmlElement In elements
If element.GetAttribute("type") = "submit" Then
element.InvokeMember("click")
Exit For
End If
Next
End Sub
I have tried to use the GetElementById("").SetAttribute("value", TextBox1.Text), but I'm having a hard time finding it. Could some one please point me in the right direction or show me some code on how to do this. Thanks so much!!!
If you want to type your username and password automatically, then you may have to take a look on AutoIt. It is a scripting anguage. You can easily do this with built-in functions. There is a COM version for AutoIt. So you can add reference to your vb.net project and import it to your class. And you can easily call almost all useful function from there. Give try. Here is the link
https://www.autoitscript.com/site/

DataGridView.rows.Cells.Style.BackColor doesn't work with MdiParent in form load event

It really drives me crazy, I have a form, I am calling a public sub called "timerss" in the form load event, when i run my form the sub "timerss" works perfectly, but when i add "Me.MdiParent = MDIParent1" in load event the sub "timerss" doesn't work!! i am really confused here!! any idea please.
Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.MdiParent = MDIParent1
timerss()
End Sub
update1:\ check the print screen of the result when running my form with and without setting MdiParent!
update2: I managed to fix part of the problem which is i got the data but what i want now is to set the color of the time cells with red, as i said the sub don't want to work, the timerss sub is:
For m As Integer = 0 To DataGridView1.Rows.Count - 1
If DataGridView1.Rows(m).Cells(4).Value > DataGridView1.Rows(m).Cells(9).Value Then
DataGridView1.Rows(m).Cells(4).Style.BackColor = Color.Red
MsgBox("red")
End If
Next
as u c in the above code i put a msgbox just to make sure that the code is working, so when i run my form the msgbox appears, but the backcolor function doesn't work when i set the MdiParent.
I don't know why the behavior is different without MDIParent, but you could try calling the sub from the DataBindingComplete event.
I had a similar problem and solved it using the event.