I am creating a program using vb6. Can somebody give me an idea on how to link vb6 program to a website search engine/weblink tool:
What I am trying to accomplish is, if I want to input a set of characters/numerc into a texbox in a vb6 form and hit enter or click button, it will open a multiple website and the value I typed into the textbox of the program should authomatically be shown (same value) into the textbox of the website search engine and will authomatically search itself.
thank you in advance. Please advise.
Last edited by jmsrickland; Sep 30th, 2015 at 06:55 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Hi jmsrickland, thank you for your help and response. It is the exact program that I want to accomplish but, what's missing is the program should open multiple website
example:
Shell("www.google.com", vbNormalFocus)
and the value I typed into the textbox (getfocus)of the program should authomatically be shown into the textbox of the website search engine(html format) and will authomatically search itself.
Does "multiple website" mean more than one website or the same website multiple times?
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
It should open more than one website, assuming all website are created under html format and the string/numeric that was inserted to the textbox of the vb6 form must get the same value into the search box of the mutiple websites that were opened
OK, so using the project I posted as an example you want to open more than one site as separate windows using the Shell function instead of using the WebBrowser control. Now, we need to know the names of all the search engines you want to use unless you have already named them (google, yahoo, msn <-- any otheres??), then take the search argument string and insert it into each search box of the sites opened. Is this correct?
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
That is correct. To be more specific, it is the telephone number that I usually use to search to this html format tool (e.i., http://wp40281.corp.ads:5621)
Does it have to be separate windows of the browser using Shell or can it be separate Forms each one using the WebBrowser control. I ask this because I think it is easier to insert the search string into the site's search box using WebBrowser than it is using Shell since I have no way of knowing how to insert the string into a running copy of IE or whatever browser you are using.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
It is a standard html program tool that I use for searching information. It is a separate windows of a browser. I was just thinking if by means of using vb6, I can call multiple browsers to display all the information that I wanted to view
Yes, just like I did with GoogleSearch you would have more Forms each one with a WebBrowser control on it and the app would just simply call each Form like it did with one Form in my GooglSerach app.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
I assume we would need to use a webbrowser control provided by vb6 and not a separate standard web browser using a shell to view the multiple tools doing a search. I believe I get the idea there. Can this call function works even if the multiple browsers works on an intranet connection?
If I knew how to pass the search string to a browser (launched by Shell) it would be better but using VB6's WebBrowser just makes it easier (for me) however, the tools would need to be programmed in the code.
You can have many WebBrowsers controls running at the same time just like multiple copies of IE running at the same time.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
We would need to use a multiple forms(webbrowsers controls ) and insert an html format link(search tool) to each dedicated webbrowser (forms). Is that the idea?
OK, I figured out how to do it with the three sites you mentioned using ShellExecute
Use the app I posted and change the code to this: Note you will not need the other Form, just the first one
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
Private Sub Form_Load()
Dim InputLine As String
Combo1.Clear
Open App.Path & "\Google Search Strings.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, InputLine
If InputLine <> vbNullString Then
Combo1.AddItem InputLine
End If
Loop
Close #1
Combo1.Text = Combo1.List(0)
Image2.MousePointer = vbCustom
Image2.MouseIcon = LoadPicture(App.Path & "\HandPointer3232.ico")
End Sub
Private Sub Combo1_KeyUp(KeyCode As Integer, Shift As Integer)
'
' Must be done in KeyUp. This doesn't work if in KeyDown
'
If KeyCode = 13 Then
Command1_Click
End If
End Sub
Private Sub Command1_Click()
Dim FoundSearchArhInComboList As Boolean
Dim ThisSearchString As String
If Combo1.Text = "" Then Exit Sub
FoundSearchArhInComboList = False
ThisSearchString = Combo1.Text
For q = 0 To Combo1.ListCount
If ThisSearchString = Combo1.List(q) Then
FoundSearchArhInComboList = True
Exit For
Stop
End If
Next q
If FoundSearchArhInComboList Then
Open App.Path & "\Google Search Strings.txt" For Output As #1
Print #1, ThisSearchString
For q = 0 To Combo1.ListCount
If Combo1.List(q) <> ThisSearchString Then
Print #1, Combo1.List(q)
End If
Next q
Close #1
Combo1.Clear
Open App.Path & "\Google Search Strings.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, InputLine
If InputLine <> vbNullString Then
Combo1.AddItem InputLine
End If
Loop
Close #1
Combo1.Text = Combo1.List(0)
Else
Open App.Path & "\Google Search Strings.txt" For Output As #1
Print #1, ThisSearchString
For q = 0 To Combo1.ListCount
Print #1, Combo1.List(q)
Next q
Close #1
Combo1.Clear
Open App.Path & "\Google Search Strings.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, InputLine
If InputLine <> vbNullString Then
Combo1.AddItem InputLine
End If
Loop
Close #1
Combo1.Text = Combo1.List(0)
End If
'
' Use Google
'
ShellExecute 0&, vbNullString, "http://www.google.com/search?q=" & frmGoogleSearch.Combo1.Text, vbNullString, vbNullString, SW_SHOWNORMAL
'
' Use Yahoo
'
ShellExecute 0&, vbNullString, "http://search.yahoo.com/search;_ylt=ApV0jxntyveJDDkQlPDu_9CbvZx4?p=" & frmGoogleSearch.Combo1.Text, vbNullString, vbNullString, SW_SHOWNORMAL
'
' Use MSN
'
ShellExecute 0&, vbNullString, "http://www.bing.com/search?q=" & frmGoogleSearch.Combo1.Text, vbNullString, vbNullString, SW_SHOWNORMAL
'
' Comment out the below three
'
'Caption = Search & " [Google Explorer]"
'frmGoogleExplorer.Show
'Me.Hide
End Sub
Private Sub Image2_Click()
Command1_Click
End Sub
Private Sub Label2_Click()
Combo1.Text = ""
End Sub
Private Sub Label3_Click()
Dim FoundSearchArhInComboList As Boolean
Dim ThisSearchString As String
If Combo1.Text = "" Then Exit Sub
FoundSearchArhInComboList = False
If MsgBox("Are you sure you want to delete this entry?", vbYesNo, "Request Delete") = vbNo Then Exit Sub
ThisSearchString = Combo1.Text
For q = 0 To Combo1.ListCount
If ThisSearchString = Combo1.List(q) Then
FoundSearchArhInComboList = True
Exit For
Stop
End If
Next q
If FoundSearchArhInComboList Then
Open App.Path & "\Google Search Strings.txt" For Output As #1
'Print #1, ThisSearchString
For q = 0 To Combo1.ListCount
If Combo1.List(q) <> ThisSearchString Then
Print #1, Combo1.List(q)
End If
Next q
Close #1
Combo1.Clear
Open App.Path & "\Google Search Strings.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, InputLine
Combo1.AddItem InputLine
Loop
Close #1
Combo1.Text = Combo1.List(0)
End If
End Sub
EDIT:
Crap! It appears that only one copy of IE can be launched. For now I guess we will have to go back to using the WebBrowser instead of IE.
I know I can have three copies of IE running at the same time but only if I launch each one at a time by double clicking on it's Desktop Icon. Using Shell it doesn't appear to work that way.
EDIT to EDIT:
It does work. I just noticed that the three sites were added as tabs so all three sites were launched. It's one IE but each site is a tab so all you have to is to tab to each one unless you want all three to show at one time on your screen then I will use Max's idea if he shows me how..
Last edited by jmsrickland; Aug 11th, 2012 at 05:23 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Why use shellexecute? You could use createobject and control your internet explorer windows and search with document
OK, so how to do that?
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
OH, I guess it does work. I just noticed that the three sites were added as tabs so all three sites were launched.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
I will show an example when i get my pc in half hour... Im not saying what you did is not good i just thought it would be better to have the control of your objects
sorry for late reply i was trying to find out more information than i thought i knew
i was trying to control each tab then i could of control each tab's document, which i found out i dont think is possible or if it is it would be alot of messing around with api calls
the only way i could control documents would be if i did with seperate windows (no tabs) only 4 different windows of ie then i could use the document...
i would go with jmsrickland or you can try this..
Code:
Option Explicit
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private IE As Object
Private Sub cmdSearch_Click()
If txtSearch = vbNullString Then
MsgBox "Please enter something to search for!", vbInformation, "Please search for something"
Exit Sub
ElseIf chkYahoo.Value = vbUnchecked And chkMSN.Value = vbUnchecked And chkGoogle.Value = vbUnchecked And chkDogpile.Value = vbUnchecked Then
MsgBox "Please select a search engine!", vbInformation, "Please select a search engine"
Exit Sub
End If
'Shell ("cmd.exe /c TASKKILL /IM iexplore.exe /F"): Sleep 1500 'close all ie windows... if needed
Set IE = CreateObject("InternetExplorer.Application")
With IE
If chkYahoo.Value = vbChecked Then .Navigate "http://ca.search.yahoo.com/search?p=" & txtSearch
If chkMSN.Value = vbChecked Then .Navigate2 "http://www.bing.com/search?q=" & txtSearch, 2048
If chkGoogle.Value = vbChecked Then .Navigate2 "http://www.google.ca/#hl=en&q=" & txtSearch, 2048
If chkDogpile.Value = vbChecked Then .Navigate2 "http://www.dogpile.com/search/web?q=" & txtSearch, 2048
.Visible = True
End With
ShowWindow IE.hwnd, SW_SHOWMAXIMIZED
'You can control ie here if you want
'Only problem is i do not know how to control every tab (if possible)
'for example
Sleep 2000 '2 sec wait (for loading pages)
Debug.Print IE.Document.Body.InnerHTML 'print innerhtml of current website (main ie window/object "IE") which in this case is yahoo
Set IE = Nothing
End Sub
and i will attach project also (see attachment)
Last edited by Max187Boucher; Aug 11th, 2012 at 10:06 PM.
Reason: Updated to show Maximized
I modified the Forms module so that you can launch multiple instances of IE each one navigating to a different search Web Sit. Also, you can control the position, width and height of each instance. The positions and size parameters are for my monitor so you would need to adjust to your own liking.
Code:
Private Sub Form_Load()
Dim InputLine As String
Combo1.Clear
Open App.Path & "\Google Search Strings.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, InputLine
If InputLine <> vbNullString Then
Combo1.AddItem InputLine
End If
Loop
Close #1
Combo1.Text = Combo1.List(0)
Image2.MousePointer = vbCustom
Image2.MouseIcon = LoadPicture(App.Path & "\HandPointer3232.ico")
End Sub
Private Sub Combo1_KeyUp(KeyCode As Integer, Shift As Integer)
'
' Must be done in KeyUp. This doesn't work if in KeyDown
'
If KeyCode = 13 Then
Image2_Click
End If
End Sub
Private Sub Image2_Click()
Dim FoundSearchArhInComboList As Boolean
Dim ThisSearchString As String
If Combo1.Text = "" Then Exit Sub
FoundSearchArhInComboList = False
ThisSearchString = Combo1.Text
For q = 0 To Combo1.ListCount
If ThisSearchString = Combo1.List(q) Then
FoundSearchArhInComboList = True
Exit For
Stop
End If
Next q
If FoundSearchArhInComboList Then
Open App.Path & "\Google Search Strings.txt" For Output As #1
Print #1, ThisSearchString
For q = 0 To Combo1.ListCount
If Combo1.List(q) <> ThisSearchString Then
Print #1, Combo1.List(q)
End If
Next q
Close #1
Combo1.Clear
Open App.Path & "\Google Search Strings.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, InputLine
If InputLine <> vbNullString Then
Combo1.AddItem InputLine
End If
Loop
Close #1
Combo1.Text = Combo1.List(0)
Else
Open App.Path & "\Google Search Strings.txt" For Output As #1
Print #1, ThisSearchString
For q = 0 To Combo1.ListCount
Print #1, Combo1.List(q)
Next q
Close #1
Combo1.Clear
Open App.Path & "\Google Search Strings.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, InputLine
If InputLine <> vbNullString Then
Combo1.AddItem InputLine
End If
Loop
Close #1
Combo1.Text = Combo1.List(0)
End If
SearchGoogle
SearchYahoo
SearchBing
End Sub
Private Sub Label3_Click()
Dim FoundSearchArhInComboList As Boolean
Dim ThisSearchString As String
If Combo1.Text = "" Then Exit Sub
FoundSearchArhInComboList = False
If MsgBox("Are you sure you want to delete this entry?", vbYesNo, "Request Delete") = vbNo Then Exit Sub
ThisSearchString = Combo1.Text
For q = 0 To Combo1.ListCount
If ThisSearchString = Combo1.List(q) Then
FoundSearchArhInComboList = True
Exit For
Stop
End If
Next q
If FoundSearchArhInComboList Then
Open App.Path & "\Google Search Strings.txt" For Output As #1
'Print #1, ThisSearchString
For q = 0 To Combo1.ListCount
If Combo1.List(q) <> ThisSearchString Then
Print #1, Combo1.List(q)
End If
Next q
Close #1
Combo1.Clear
Open App.Path & "\Google Search Strings.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, InputLine
Combo1.AddItem InputLine
Loop
Close #1
Combo1.Text = Combo1.List(0)
End If
End Sub
Private Sub SearchGoogle()
Set IE = CreateObject("internetexplorer.application")
IE.Navigate2 "http://www.google.com/search?q=" & frmGoogleSearch.Combo1.Text
IE.Left = 15 / Screen.TwipsPerPixelX
IE.Top = 120 / Screen.TwipsPerPixelY
IE.Width = 5085 / Screen.TwipsPerPixelX
IE.Height = 5910 / Screen.TwipsPerPixelY
IE.Visible = True
Set IE = Nothing
End Sub
Private Sub SearchYahoo()
Set IE = CreateObject("internetexplorer.application")
IE.Navigate2 "http://search.yahoo.com/search;_ylt=ApV0jxntyveJDDkQlPDu_9CbvZx4?p=" & frmGoogleSearch.Combo1.Text
IE.Left = 5100 / Screen.TwipsPerPixelX
IE.Top = 120 / Screen.TwipsPerPixelY
IE.Width = 5085 / Screen.TwipsPerPixelX
IE.Height = 5910 / Screen.TwipsPerPixelY
IE.Visible = True
Set IE = Nothing
End Sub
Private Sub SearchBing()
Set IE = CreateObject("internetexplorer.application")
IE.Navigate2 "http://www.bing.com/search?q=" & frmGoogleSearch.Combo1.Text
IE.Left = 10185 / Screen.TwipsPerPixelX
IE.Top = 120 / Screen.TwipsPerPixelY
IE.Width = 5085 / Screen.TwipsPerPixelX
IE.Height = 5910 / Screen.TwipsPerPixelY
IE.Visible = True
Set IE = Nothing
End Sub
Last edited by jmsrickland; Aug 12th, 2012 at 06:48 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Your samples did work to my project, Thanks to your guys.
I was just playing with it and I am linking an html format program tool where I can use as a search engine and it doesn't work. Would it be possible to use my own tool as a search engine?
You might want to explain a little better what you are referring to. What is this html format tool you are talking about? What is your own tool?
I thought all the sample codes you got solved your problem. What's up now?
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
I already have that(google,msn,yahoo) working except I am using an entranet made html program tool that I need it to run as well the tool is http://wp40281.corp.ads:5621
I already have that(google,msn,yahoo) working except I am using an entranet made html program tool that I need it to run as well the tool is http://wp40281.corp.ads:5621
Link is no good
Anyway I don't under stand your question about would it be possible to use my own tool as a search engine?
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.