Sorry for the double post, just thought it would be better this way
Ok, so here is my code
code:
Public Class miniSearch
Inherits System.Windows.Forms.Form
Private URLString As String
Private Declare Function ShellExecute Lib "SHELL32" 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
Private Sub txtSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtSearch.Click
If txtSearch.Text = "Enter search words here" Then
txtSearch.Text = ""
End If
End Sub
Private Sub txtSearch_KeyPress(ByVal KeyAscii As Integer)
If KeyAscii = 13 Then
cmdSearch.PerformClick()
ElseIf KeyAscii = 27 Then
End
End If
End Sub
Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSearch.Click
URLString = "http://www.google.ca/search?q=" & Replace$(txtSearch.Text, " ", "+")
ShellExecute(0&, vbNullString, URLString, vbNullString, vbNullString, vbNormalNoFocus)
MsgBox(URLString)
End
End Sub
End Class
First off, the "cmdSearch.PerformClick()" doesn't work, in fact the whole KeyPress part doesnt' work. I tried sending my KeyPress into a msgBox and that doesn't even work, could it be because i don't ahve a hangle on it ?
Edit: OK, i tried with a handle "Handles txtSearch.KeyPress" and i get this error: "Method 'txtSearch_KeyPress' cannot handle Event 'KeyPress' because they do not have the same signature."
Edit2: Alright, after some digging, i found out the KeyPress was redefined in .NET. And to make it work, u need code that looks like this
code:
Private Sub txtSearch_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtSearch.KeyPress
Dim KeyAscii As Integer
KeyAscii = AscW(e.KeyChar) <-- This is the code to make it work
If KeyAscii = 13 Then
cmdSearch.PerformClick()
ElseIf KeyAscii = 27 Then
End
End If
End Sub
So that thing is solved
And second, it doesn't the launch my browser. Maybe i just overlooked something
Edit: Woohoo, i got it wo work
by bypassing the API too
Here's how i did it
code:
System.Diagnostics.Process.Start(URLString)
Well all works now
Once it'll all finalized and what not i'll post it here, if anyone wants it