call a function/sub on button click vb.net [closed] - vb.net

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
i have a button when clicked, a document will open...
Private Sub btnPrintDTR_Click(sender As Object, e As EventArgs) Handles btnPrintDTR.Click
'function/sub to call
End Sub
in the "function to call", i want this Sub DefineTables(ByVal document As Document)
to be called.
i was able to call Function SearchRecord() As DataTable on button click using this code
DataGridView1.DataSource = SearchRecord()
i wanted a similar call but i could not figure out how to.
anyone have any idea on this?

I was interested to learn that you are system developer. One of the first things my husband would do when interviewing was to ask about items on the applicants resume.
I have no idea what type of Document your code refers to.
Private Sub btnPrintDTR_Click(sender As Object, e As EventArgs) Handles btnPrintDTR.Click
Dim doc As New Document
DefineTables(doc)
End Sub

oh now i get it...
by observing lots of functions...
Private Sub btnPrintDTR_Click(sender As Object, e As EventArgs) Handles btnPrintDTR.Click
DefineTables(document)
End Sub

Related

ListBox item actions [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a listbox with a list of items and I want to give them actions when clicked, unfortunately when I try to double click the listbox, the action is applied to the whole listbox and I'm not being able to find tips anywhere on how to give an action to each item on a listbox.
In this case I want a click on an item on the listbox to display a youtube video on webbroswer1
So I've been asked to be less vague...I want to get each ITEM on a Listbox to navigate to a different webbrowser page. I have no more code than the one posted below...
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
Dim curItem As String = ListBox1.SelectedItem.ToString()
WebBrowser1.Navigate("http://www.youtube.com/embed/ECIupNr8U-o")
Someone able to help?
Regards
If each item is a valid address then:
Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
If Not Listbox1.SelectedIndex = -1 Then
WebBrowser1.Navigate(ListBox1.SelectedItem.ToString())
End If
End Sub

Browse for a file and place the data in the text box [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
when i click the "browse" button I need to browse for a txt/xml file and place the data of that file in the text box.So for this I tried with a code but I was not successful.So can you help me with the vb.net code for this
If think that the problem is in your if statement. Here is an example of what you can do:
Imports System.IO
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If My.Computer.FileSystem.FileExists("Your Path") = True Then
TextBox1.Text = My.Computer.FileSystem.ReadAllText("Your Path")
Else
MsgBox("ERROR - File Not Found")
End If
End Sub
End Class
Notice the change I did in the If Statement. Hoped it helped.

Event Handler In Vb.Net [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I use online converters to convert C# code to Vb.Net,but it does not properly convert event handler code.Kindly help me out.Here is my two functions:
Private Sub OnPopup(sender As Object, e As PopupEventArgs)
'Piece Of Code
End Sub
Private Sub OnDraw(sender As Object, e As DrawToolTipEventArgs)
'Piece Of Code
End Sub
The online converters convert it as follows:
Me.Popup += New PopupEventHandler(AddressOf Me.OnPopup)
Me.Draw += New DrawToolTipEventHandler(AddressOf Me.OnDraw)
Kindly tell me,how to tackle this in Vb.Net
Expounding on my comment, you are looking for the AddHandler Method.
in your case it would be
AddHandler Me.Draw, AddressOf OnDraw
AddHandler Me.Popup, AddressOf OnPopup
or you can just use Handles which is what the designer uses like #bansi stated.
Private Sub OnPopup(sender As Object, e As PopupEventArgs) Handles Me.Popup
'Piece Of Code
End Sub
Private Sub OnDraw(sender As Object, e As DrawToolTipEventArgs) Handles Me.Draw
'Piece Of Code
End Sub

I am looking for someone that has patience to help me understand VB terminology and the hows and whys [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Some basic terms that interchange that i have no one to ask, and i guess to stupid to understand my self.
Method,procedure, parameters, operation, operator, function, instaniantiantion, separator,
I really need help!
I really need to see a long module of code that every thing is broken down for a stupid guy like me.
For instance break this down, not what it does but how it does it, and the terminology. Word by word,, all dots, = parentheses, the passes the gets all that stuff, I know that this is simple to everyone else. And i will need more help until i get it... Maybe we can work something out. Some one that is available,,, that knows this stuff backwards and forwards and has the patience, that would like to help me... I have tried books i just do not get it HELP
Public Class ViewerForm1
Private Sub btnSelectPicture_Click(sender As Object, e As EventArgs) Handles btnSelectPicture.Click
'Show the open dialog box.
If ofdSelectPicture.ShowDialog = DialogResult.OK Then
'Load the picture in the box.
btnSelectPicturePicture.Image = Image.FromFile(ofdSelectPicture.FileName)
'Show the name of the file in the forms caption.
Me.Text = "Picture Viewer "(ofdSelectPicture.FileName)
'Close the window at exit the application.
Me.Close()
End If
End Sub
Private Sub btnSelectPicture_Click(sender As Object,
e As EventArgs) Handles btnSelectPicture.Click
This line declares a default Click event handler and binds button's click event to it.
If ofdSelectPicture.ShowDialog = DialogResult.OK Then
Opens an open file dialog and if user presses OK, processes the result.
btnSelectPicturePicture.Image = Image.FromFile(ofdSelectPicture.FileName)
Loads the image into the button, based on the file previously selected.
Me.Text = "Picture Viewer "(ofdSelectPicture.FileName)
Line does not make sense and probably won't compile. Missing a & or a + for string concatenation. Assuming it had one, it would assign a form caption/title to a constant value + a file name that was selected.
Me.Close()
Closes the current form.

How can I click a button in VB and then can be able to type in the text box? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
This question is about having a button and text box. And when you click the button, the text in the text box then can be written on, in one quick move. I'm building this code in VB (Microsoft, Visual Basic 2010).
Textbox is disabled by default when user click's the button textbox should be enabled
Private Sub btnKey_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnButtons.Click
[...]
End Sub
Try this:
Sub btnKey_Click(sender As Object, e As EventArgs) Handles btnButtons.Click
TextBox1.Focus()
End Sub
Have your textbox enabled set to false from the start.
textbox1.Enabled = false
And at your btnKey_Click set it to true
textbox1.Enabled = true
If this is what you are asking for you realy could have spend some time on google or msdn.