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
Related
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
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 4 years ago.
Improve this question
[so i put the string like "hello world" and want to change "l" to "a" then i need to count the no. of changed letters how do i count the change letters only? help pls[1]: https://i.stack.imgur.com/Wu1PF.jpg
a possible solution would be computing the length difference between the input string and the same one with find string substituted with "":
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
newStringTB.Text = inputTB.Text.Replace(findTB.Text, replaceTB.Text)
noOfReplacedTB.Text = Len(inputTB.Text) - Len(Replace(inputTB.Text, findTB.Text, ""))
End Sub
just change:
"Button1" to your actual command button name
"newStringTB", "findTB", "replaceTB" and "noOfReplacedTB" to your actual textboxes names
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
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim reader As StreamReader = My.Computer.FileSystem.OpenTextFileReader(TextBox1.Text)
Dim a As String
a = reader.ReadLine
RichTextBox1.Text = RichTextBox1.Text + a
Label5.Text = RichTextBox1.Text.Substring(5, a.Substring(5, a.Length))
reader.Close()
End Sub
Hello. I am trying to read a text file and put the numbers in different variables. The textfile is like this
IMAGE
Every time i run the code it comes out with an error. What should i do?
What is it that you're trying to do with this line?
Label5.Text = RichTextBox1.Text.Substring(5, a.Substring(5, a.Length))
This part: a.Substring(5, a.Length) returns a string, but the second argument of Substring expects an integer, so it is causing an error.
Substring looks like this: Substring(startIndex As Integer, length As Integer). You are trying to pass a string into the second argument.
Simply dropping the second argument from that line seems that it would do what you want it to:
Label5.Text = RichTextBox1.Text.Substring(5)
If these types of problems are frequently affecting you, I highly suggest you turn Option Strict on in Visual Studio. Here are some instructions on how to do so.
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.
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.