Arrow[Help]WebBrowser

Posts 1–15 of 18 · Page 1 of 2
[Help]WebBrowser
hello i was wondering that if i clicked a button it is going to get the text in a txt box and upload it to a list box. when i restart my app that txt is going to reappear in the listbox. i want to add the bookmarks thing in my web browser
Ini file or my.settings.
Well, i feel that My.Settings is sorta temperamental for this sorta text stuff.

For the adding to the listbox, use this:

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListBox1.Items.Add(TextBox1.Text)
    End Sub
I'm not sure about the settings, so i'll leave it to Blubb or Flamesaber , etc
Button1 click event.

[php]listbox1.items.add(textbox1.text)
[/php]

And on form1 load:
[php]
imports system.io ' Import statement

Dim Xread as system.io.streamreader
Xread = File.open(application.startuppath & "\file.txt")

Do until Xread.EndOfStream
listbox1.items.add(Xread.readline)
Loop

[/php]

form1 closing:

[php]
for each item in listbox1.items
Dim save As IO.StreamWriter(application.startuppath & "\file.txt")
save.write(item)
if listbox1.selectedindex = listbox1.items.count -1 then
save.close()

next

[/php]

Hopefully this works, wrote it on my netbook so idk
HAH! Beat you to the Button1Code.
But naww. Good job on the Settings.

Edit: I tried your solution. Error.
Form1_Load
Xread = File.OpenText(Application.StartupPath & "\file.txt")
Should be OpenText not Open, it doesn't accept that many arguments.

Also,
Dim save As New StreamWriter(Application.StartupPath & "\file.txt")
I edited it, its not IO.Streamwriter but New StreamWRiter
Quote Originally Posted by Invidus View Post
HAH! Beat you to the Button1Code.
But naww. Good job on the Settings.

Edit: I tried your solution. Error.
Form1_Load
Xread = File.OpenText(Application.StartupPath & "\file.txt")
Should be OpenText not Open, it doesn't accept that many arguments.

Just wrote it here in the MPGH textbox.
Dont have VB on my netbook
Quote Originally Posted by Zoom View Post



Just wrote it here in the MPGH textbox.
Dont have VB on my netbook
Why not? I have it on mine. Then again, this is my only computer right now since my old one died permnently...
Lawl i know.
And another error O.o sorry

As i'm not as nearly experienced as you but i have VB,

Xread = File.OpenText(Application.StartupPath & "\file.txt")

It will not allow you to run it unless you have ran it before, because it requires the Text to exist.

So could you create a code where it:

CHECKS if it exists first, and if it doesn't, continue on.
Zoom how did you get form1.closing
Quote Originally Posted by hopefordope View Post
Zoom how did you get form1.closing
When you're in the code section of your project you will notice 2 drop down bars at the top



Click the left one and choose: (form1 events)

then click the second one and choose: Form Closing

It'll set up the template sub procedure for you, then add the code.

I just use this function for reading:

Make this import

[php]
Imports System.IO
[/php]

Then make this function to read files.

[php]
Private Function Readit(ByVal file As String)

Dim lbitems As String = ""
try
Using sr As Streamreader = New Streamreader(file)

lbitems = sr.readline

Do While (Not lbitems Is Nothing)

ListBox1.Items.Add(lbitems)

Console.WriteLine(lbitems)

lbitems = sr.ReadLine

Loop

End Using
catch ex as Exception

MsgBox("An error occurred: " & ex.ToString)
Return lbitems

End Function

[/php]

Then to use it

[php]
If My.Computer.FileSystem.FileExists(application.star tuppath & "\items.txt") then

readit((application.startuppath & "\items.txt")

End if
[/php]

You should be able to play around with that to get it to write as well. I've got school now so I can't finish it off haha.
ah i have one more request

how do i make it so that the person gets to rename the url(txtbox1.txt) to what they want but it still navigates to the original webpage
Quote Originally Posted by hopefordope View Post
ah i have one more request

how do i make it so that the person gets to rename the url(txtbox1.txt) to what they want but it still navigates to the original webpage
Sounds like TextBox1.Text does pretty much nothing so just do this on whatever it is that call the webpage .

[php]
WebBrowser1.Navigate("FictionalSite.com")
[/php]

They can type whatever they want in the textbox because WebBrowser doesn't navigate using the textbox.

Not sure if that's what you meant.
i meant that i use my textbox as the navigator

what i meant was...

if i press the button it adds the webpage's full url which is sometimes quite long..... so i was wondering if i can rename the long url to something short but it still navigates to the original url.
hey guys when i debug it points to

Xread = File.OpenText(Application.StartupPath & "C:\Users\lemo\Desktop\file.ini")

and says "The given path's format is not supported."

what can i do?


A. For Making a shorter Name for URL set the Addressbar = webbrowser.documenttitle

Similar to what phones and some browser do.

B. The proper format for file location is a special directory

[php]
xRead = File.OpenText(My.Computer.FileSystem.SpecialDirect ories.Desktop & "/file.ini")
[/php]

or wherever the actual file is, in this case you are telling it that the file is in your application start up path (so lets say bin...) then to navigate to the C: inside the application path, which is not correct.

essentially, you are telling your application to

{example, my start up path is C:\windows\nextgen\sample}

Your code

[php]
Application.StartupPath & "C:\Users\lemo\Desktop\file.ini")
[/php]

pragmatically and literary reads

Code:
C:\windows\nextgen\sample & C:\Users\lemo\Desktop\file.ini
Which makes the full path to navigate to

Code:
C:\windows\nextgen\sampleC:\Users\lemo\Desktop\file.ini
I am sure you can see the problem now

Posts 1–15 of 18 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?