Code For: Button Click = Web Link

Posts 1–15 of 20 · Page 1 of 2
Code For: Button Click = Web Link
Visual basics 2008 Express Edition


Yes, ok lets say Button_1 i put on Windows Application, and whats the code, if i want it, when click lets say it opens Google

Thanks
try

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        System.Diagnostics.Process.Start("http://www.mpgh.net")
End Sub
I'm not to good with vb08, and can't test that.

I can guarantee
Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1

Private Sub command1_Click()
      ShellExecute Me.hwnd, vbNullString, "http://www.mpgh.net/", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
will work for vb6.0
Quote Originally Posted by legendaryhack b leet View Post
try

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        System.Diagnostics.Process.Start("http://www.mpgh.net")
End Sub
I'm not to good with vb08, and can't test that.

I can guarantee
Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Const SW_SHOWNORMAL = 1

Private Sub command1_Click()
      ShellExecute Me.hwnd, vbNullString, "http://www.mpgh.net/", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
will work for vb6.0
btw if you want that vb6 command to work in vb2008 just replace command1 with button1 and replace Me.hwnd with Me.Handle ( handle is the vb.net form of hwnd)
what he said.
Thanks!

Wait the Thanks button is gone =X

Close please =D
Refresh the page and it will be there

Although this is a secondary account so doesn't really matter.
Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate(TextBox1.Text)
    End Sub
End Class
Ima beginner too . I just finish watching the tut video on it^
so im not 100% sure that it will work.
Im chooby in vb cuz i just started. i wanna learn more
Quote Originally Posted by JIGS4W View Post
Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate(TextBox1.Text)
    End Sub
End Class
Ima beginner too . I just finish watching the tut video on it^
so im not 100% sure that it will work.
Im chooby in vb cuz i just started. i wanna learn more
It will work like that,
but you need to add a webbrowser and a textbox first.
If you need any info on VB, or need some tutorials, PM me and ill be happy to help you out.
What does the textbox do in that?

Do you like type the website name in it or something?

Here is my very crappy vb project. feel free to laugh, its my first vb ive ever done
btw its a program to browse websites with

Quote Originally Posted by K4GE View Post
It will work like that,
but you need to add a webbrowser and a textbox first.
If you need any info on VB, or need some tutorials, PM me and ill be happy to help you out.
Ill definitely PM you if I need help with vb lol
Quote Originally Posted by legendaryhack b leet View Post
What does the textbox do in that?

Do you like type the website name in it or something?
I think its for typing the website. Not sure... still learning.
You type the website in the TextBox, and then click a button.
Then the button will 'navigate' the webbrowser to the text inside the textbox.
You can compare it with a normal webbrowser (like firefox, internet explorer, safari,etc..).
Look at this image i made:

I hope you understand it now. (:
Button1 on firefox is the green arrow as such

But yes to the thread starter, what I posted is what you are looking for you can use this in a different instance
process.start("Http://Mpgh.net/")
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ShellExecute Me.Handle, vbNullString, "http://www.mpgh.net/", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
So that?
Posts 1–15 of 20 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

Talk with us