Search Engine Save Ability

I need to save the settings of the user.

Page 1 of 1

12 Replies - 1285 Views - Last Post: 28 February 2009 - 11:03 PM Rate Topic: -----

#1 TroyErvin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 23-February 09

Search Engine Save Ability

Posted 23 February 2009 - 11:04 PM

Hi there,

I have a system on my webbrowser that allows the user to choose their Search Engine out of a selection I organized. the down point is that I have it set so when they click save it will just hide, because if it closes the settings will be reset and not saved. However I want them to save. Here are my codes to the search button:

	Private Sub Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Search.Click
		If SearchEngines.RadioButton1.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.google.com/search?hl=en&q=" & SearchBar.Text & "&btnG=Google+Search&meta=")
		End If
		If SearchEngines.RadioButton2.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://search.yahoo.com/search?p=" & SearchBar.Text & "&fr=yfp-t-501&toggle=1&cop=mss&ei=UTF-8&fp_ip=IN&vc=")
		End If
		If SearchEngines.RadioButton3.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://images.google.ca/images?hl=en&q=" & SearchBar.Text)
		End If
		If SearchEngines.RadioButton4.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://en.wikipedia.org/wiki/Special:Search?search=" & SearchBar.Text)
		End If
		If SearchEngines.RadioButton6.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://video.google.com/videosearch?q=" & SearchBar.Text)
		End If
		If SearchEngines.RadioButton5.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.youtube.com/results?search_type=&search_query=" & SearchBar.Text)
		End If
		If SearchEngines.RadioButton7.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.ask.com/web?q=" & SearchBar.Text & "&search=&qsrc=0&o=0&l=dir")
		End If
		If SearchEngines.RadioButton8.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://news.google.ca/news?hl=en&tab=ln&nolr=1&q=" & SearchBar.Text)
		End If
End Sub


This is the code of save:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Me.Hide()
	End Sub


I would like it so it saves when the whole program is closed, so when they start up it's automatically set so they can search on their favourite search engine.

Is This A Good Question/Topic? 0
  • +

Replies To: Search Engine Save Ability

#2 UnknownCoder  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 5
  • View blog
  • Posts: 137
  • Joined: 22-February 09

Re: Search Engine Save Ability

Posted 24 February 2009 - 05:05 AM

Use the My.Settings statement to save settings.
Was This Post Helpful? 0
  • +
  • -

#3 TroyErvin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 23-February 09

Re: Search Engine Save Ability

Posted 24 February 2009 - 04:47 PM

I'm unfamiliar with using this part of code. can you use assist me?
Was This Post Helpful? 0
  • +
  • -

#4 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Search Engine Save Ability

Posted 24 February 2009 - 04:59 PM

Here's some information on the My.Settings Object. Hope that helps :)
Was This Post Helpful? 0
  • +
  • -

#5 TroyErvin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 23-February 09

Re: Search Engine Save Ability

Posted 24 February 2009 - 05:13 PM

View PostPsychoCoder, on 24 Feb, 2009 - 03:59 PM, said:

Here's some information on the My.Settings Object. Hope that helps :)


Thanks for the reply but I am new at this and I don't understand what I have to do for that with this sight, it must be something I'm missing but is there anyone willing to code for me?
Was This Post Helpful? 0
  • +
  • -

#6 Wrecks  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 71
  • Joined: 24-February 09

Re: Search Engine Save Ability

Posted 24 February 2009 - 10:09 PM

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
	Me.Hide()
	My.Settings.Save()
End Sub

Was This Post Helpful? 0
  • +
  • -

#7 TroyErvin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 23-February 09

Re: Search Engine Save Ability

Posted 25 February 2009 - 12:20 AM

View PostWrecks, on 24 Feb, 2009 - 09:09 PM, said:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
	Me.Hide()
	My.Settings.Save()
End Sub


Hi thanks for the reply but when i open the program its still on the default set, is there somewhere to load it?
Was This Post Helpful? 0
  • +
  • -

#8 Ameel  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 171
  • Joined: 19-June 08

Re: Search Engine Save Ability

Posted 25 February 2009 - 12:37 AM

I'm pretty sure you didn't read the webpage.
Basically you need to create a settings object in your app.
Then use that object to store whatever info you need, and refer to that object when your app loads.

e.g I have a textbox that a user can insert a text in, which I want to save.

In Properties>Settings of my project,
I add a new setting called "UserText" of Type String with User Scope

In my main app, code as follows

	Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		TextBox1.Text = My.Settings.UserText
	End Sub

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		My.Settings.UserText = TextBox1.Text
		My.Settings.Save()
	End Sub



This post has been edited by Ameel: 25 February 2009 - 12:40 AM

Was This Post Helpful? 0
  • +
  • -

#9 TroyErvin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 23-February 09

Re: Search Engine Save Ability

Posted 25 February 2009 - 12:54 AM

Hi thanks for the reply,


How do I do this with Radio Buttons? And they not on main form, so do i still put the load on form1.vb or options.vb?
Was This Post Helpful? 0
  • +
  • -

#10 Ameel  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 171
  • Joined: 19-June 08

Re: Search Engine Save Ability

Posted 25 February 2009 - 05:43 AM

A simple example of what you can do (given I'm not really sure you want to save anyway....)
Private Sub Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Search.Click
		If SearchEngines.RadioButton1.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.google.com/search?hl=en&q=" & SearchBar.Text & "&btnG=Google+Search&meta=")
my.settings.searchengine = 0
		End If
		If SearchEngines.RadioButton2.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://search.yahoo.com/search?p=" & SearchBar.Text & "&fr=yfp-t-501&toggle=1&cop=mss&ei=UTF-8&fp_ip=IN&vc=")
my.settings.searchengine = 1
		End If
		If SearchEngines.RadioButton3.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://images.google.ca/images?hl=en&q=" & SearchBar.Text)
my.settings.searchengine = 2
		End If
		If SearchEngines.RadioButton4.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://en.wikipedia.org/wiki/Special:Search?search=" & SearchBar.Text)
my.settings.searchengine = 3
		End If
		If SearchEngines.RadioButton6.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://video.google.com/videosearch?q=" & SearchBar.Text)
my.settings.searchengine = 4
		End If
		If SearchEngines.RadioButton5.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.youtube.com/results?search_type=&search_query=" & SearchBar.Text)
my.settings.searchengine = 5
		End If
		If SearchEngines.RadioButton7.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.ask.com/web?q=" & SearchBar.Text & "&search=&qsrc=0&o=0&l=dir")
my.settings.searchengine = 6
		End If
		If SearchEngines.RadioButton8.Checked Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://news.google.ca/news?hl=en&tab=ln&nolr=1&q=" & SearchBar.Text)
my.settings.searchengine = 7
		End If
my.settings.save
End Sub



Then in your main form load event
	Private Sub Window1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
		select case my.settings.searchengine
case 0
'Since you already know case 0 corresponds to 1st searchengine, do whatever you want here

case 1

case 2

case 3

case 4

case 5

case 6

case 7
end select
	End Sub



Above is an indirect way of doing whatever you wanted to do.
You can probably, hopefully, figure out a more direct way once you understand how this thing works.
You could probably explain better what you want to do.can then probably work something better out

This post has been edited by Ameel: 25 February 2009 - 05:45 AM

Was This Post Helpful? 0
  • +
  • -

#11 Wrecks  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 71
  • Joined: 24-February 09

Re: Search Engine Save Ability

Posted 25 February 2009 - 09:09 AM

Here is what I would do:

Save the setting in the RadioButton1_CheckedChanged event every time it happens. The state will be saved on the fly as the program runs and you don't have to "clean up" with a final save. It also has the benefit of saving the current state of the radio buttons even if the program crashes.
Was This Post Helpful? 0
  • +
  • -

#12 TroyErvin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 23-February 09

Re: Search Engine Save Ability

Posted 25 February 2009 - 05:19 PM

Thanks for the reply but where do I place this code?
Was This Post Helpful? 0
  • +
  • -

#13 Wrecks  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 71
  • Joined: 24-February 09

Re: Search Engine Save Ability

Posted 28 February 2009 - 11:03 PM

View PostTroyErvin, on 25 Feb, 2009 - 04:19 PM, said:

Thanks for the reply but where do I place this code?

Did you miss the part where I said "Save the setting in the RadioButton1_CheckedChanged event"?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1