VB.Net-Forum - Beitragsübersicht -
Von Engineering Student
E-Mail linksalias@web.de
Datum 18. April 2015 um 18:21:04
Frage Hallo Zusammen,

zuerst einmal entschuldige ich mich für das seltsame Deutsch des Themas, leider war die Zeile zu kurz also erkläre ich euch ausführlich worum es geht und hoffe das Ihr mir helfen könnt :)

Zuallerst studiere ich und wurde seit einigen Wochen mit Visual Basic 2012 (Visual Studios 2012) konfrontiert. Somit ist es noch sehr neu für mich.
Leider rückt mein Abgabetermin immer näher udn ich denke ich schaffe das nicht mehr alleine.

Ich soll einen WEBBROWSER konstruieren.
Dabei sind folgende Bedingungen wichtig:
-Der URL des WbBrowser in das Textfeld einlesen (funktioniert)
-Bestätigung mit Entertaste oder GoTaste (funktioniert)
- Verschiedene Tasten wie vor, zurück, refresh und Home (funktioniert aber alles)
-Favouriten in eine Combobox speichern durch Knopfdruck von Add dabei wird abgefragt wie man die Webseite kurz beschreibt, die Beschreibung wird nur angezeigt, bei Klick wird der entsprechende Favourite aufgerufen.(funktioniert bedingt)
-Favouritenliste auf Knopfdruck von Save automatisch auf die Festplatte speichern (funktioniert bedingt)
-Bei Starten des Programmes soll automatisch die Favouritenliste falls vorhanden geladen werden und wenn nicht vorhanden keine Fehlermeldung anzeigen (funktioniert bedingt)
-Im Hintergrund eine versteckte Historienliste laufen lassen die nicht angezeigt werden muss aber auf 50 Einträge beschränkt ist. (sollte soweit funktionieren)

Ich habe jetzt zwei große Probleme...
Zu erst bekomme ich es hin die Datei manuell speichern und laden zu lassen, soweit ok.
Aber ich schaffe es nicht fehlerfrei das zu automatisieren.

Das andere Problem ist das mir der "FavouriteURL" nicht im Array abgespeichert wird sondern immer nur der Name und unter URL kommt die Aussage "Nothing" und ich weiß nicht warum weil er mir beim debugging Prozess anzeigt das sich dort Inhalt befindet und zwar der richtige Wert.

Ich bin euch außerordentlich Dankbar für jeden Hinweiß den Ihr mir geben könnt und gebt mir bitte Bescheid wenn etwas nicht klar sein sollte

Anbei der Code mit reichlich Kommentaren damit man einen Überblick gewinnt. :)
Public Class Form1


'Declare of variable (Public variable)
Dim FavouriteName As String
Dim FavouriteURL As String
Dim ComboIndex As Integer

'Array of favourite information
<Serializable()> Structure FavouriteData
Dim FavouriteName As String
Dim FavouriteURL As String

'Subroutine To create New record containing two pieces of information
Public Sub New(ByVal Name As String, ByVal URL As String)
FavouriteName = Name
FavouriteURL = URL

End Sub

End Structure

'Creates a two dimensional array containing unlimeted records, Each record holding two pieces of information
Private FavouriteInfo(50) As FavouriteData 'Array of favourite information

Private Sub BtmGo_Click(sender As Object, e As EventArgs) Handles BtnGo.Click
'Go To URL page

On Error Resume Next

If txtURL.Text <> "" Then
'Get web page address from text box And navigate To web page
Call WbBrowser.Navigate(txtURL.Text)
End If

End Sub

Private Sub txtURL_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtURL.KeyPress
'Goto web page If "Enter" pressed
Dim keyAscii As Char

keyAscii = e.KeyChar
If (keyAscii = vbCr) Then
If txtURL.Text <> "" Then
'Get web page address from text box And navigate To web page
Call WbBrowser.Navigate(txtURL.Text)
End If
End If
End Sub

Private Sub WbBrowser_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WbBrowser.DocumentCompleted
'Get current web page address And display In text window

'Creates a one dimensional array containing 50 records, Each record holding a webadress
Dim HistoryInfo(49) As String 'Array of history
Dim URLAddress As String 'Variable For String

URLAddress = e.Url.ToString

txtURL.Text = e.Url.ToString

URLAddress = HistoryInfo(49)

End Sub

Private Sub BtnBack_Click(sender As Object, e As EventArgs) Handles BtnBack.Click
'Go To previous side

If (WbBrowser.CanGoBack = True) Then
WbBrowser.GoBack()
End If
End Sub

Private Sub BtnForward_Click(sender As Object, e As EventArgs) Handles BtnForward.Click
'Go To forward page

If (WbBrowser.CanGoForward = True) Then
WbBrowser.GoForward()
End If
End Sub

Private Sub BtnHome_Click(sender As Object, e As EventArgs) Handles BtnHome.Click
'Go To homepage

If (WbBrowser.CanSelect = True) Then
WbBrowser.GoHome()
End If
End Sub

Private Sub BtnRefresh_Click(sender As Object, e As EventArgs) Handles BtnRefresh.Click
'Refresh the actual webpage

If (WbBrowser.CanSelect = True) Then
WbBrowser.Refresh()
End If
End Sub

Private Sub BtnAdd_Click(sender As Object, e As EventArgs) Handles BtnAdd.Click
'Save the current page To favourite pages

'require a short discription
FavouriteName = InputBox("Enter a short discription", "New Favourite")

If FavouriteName = "" Then GoTo CancelEntry
'While (FavouriteInfo(ComboIndex).FavouriteName <> "")
'Save the Url from the textbox To the variable
FavouriteURL = txtURL.Text

CancelEntry:

'Add favourite discription To the favourite list And Let the field empty
FavouriteBox.BeginUpdate()
FavouriteBox.Items.Add(FavouriteName)
FavouriteBox.Text = ""
FavouriteBox.EndUpdate()

ComboIndex = FavouriteBox.SelectedIndex
'Get current index related To position of item
'Create record In FavouriteInfo array holding name, Url at same location As combobox
'Name appears In Combobox list And In Favourite array
FavouriteInfo(ComboIndex) = New FavouriteData(FavouriteName, FavouriteURL)

End Sub

Private Sub FavouriteBox_Click(sender As Object, e As EventArgs) Handles FavouriteBox.SelectedIndexChanged
'Take the URl from FavouriteBox selection And screen On the webbrowser

'The selected Index read the Index from the array
ComboIndex = FavouriteBox.SelectedIndex
'Read the URL from the array because of the number which belongs To it
FavouriteURL = FavouriteInfo(ComboIndex).FavouriteURL

'Navigation To Webbrowser
WbBrowser.Navigate(FavouriteURL)

End Sub

Private Sub BtnSave_Click(sender As Object, e As EventArgs) Handles BtnSave.Click
'Save FavouriteBox To Folder

Dim Save As New SaveFileDialog()
'Formats data As Binary stream
Dim BufForm As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
'Stream data To I/O device
Dim MemStream As New System.IO.MemoryStream()

'Two possible file filter selections, text Or all files
Save.Filter = "txt files (*.txt)|*txt|All files (*.*)|*.*"
'Filter Is using first Option
Save.FilterIndex = 1

'Open dialog Save As txt document If OK Button pressed. No save If cancel pressed
'Dialog takes care of correct filename format etc.
If Save.ShowDialog() = Windows.Forms.DialogResult.OK Then
BufForm.Serialize(MemStream, FavouriteInfo)
'Write all data In EmployeeInfo To I/O device
My.Computer.FileSystem.WriteAllBytes(Save.FileName, MemStream.GetBuffer(), False)
End If

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'Open uo Default directory For file load selection
'Don't load anything If cancel pressed

Dim Open As New OpenFileDialog()
Dim BufForm As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()
'Stream data To I/O device
Dim MemStream As New System.IO.MemoryStream()
'File adress initialised As blank
Dim FileAddress As String = ""
'Storeage of data from I/O device
Dim DataStream As Byte()
'Index into combobox
Dim Index As Integer

'Two possible file filter selections, text Or all files
Open.Filter = "txt files (*.txt)|*txt|All files (*.*)|*.*"
'Filter Is using first Option
Open.FilterIndex = 2

'Select file And load If OK button selected
If Open.ShowDialog() = Windows.Forms.DialogResult.OK Then
FileAddress = Open.FileName
'Stream all data from I/O system
DataStream = My.Computer.FileSystem.ReadAllBytes(FileAddress)
'Load back into array of structures
FavouriteInfo = BufForm.Deserialize(New System.IO.MemoryStream(DataStream))
'Copy names To combobox list
Index = 0
FavouriteBox.BeginUpdate()
'Stop loading when favourite name Is empty
While (FavouriteInfo(Index).FavouriteName <> "")
FavouriteBox.Items.Add(FavouriteInfo(Index).FavouriteName)
Index = Index + 1
End While
FavouriteBox.EndUpdate()
End If

End Sub

Private Sub txtURL_TextChanged(sender As Object, e As EventArgs) Handles txtURL.TextChanged

End Sub
End Class
[ Antwort schreiben | Zurück zum VB.Net-Forum | Forum-Hilfe ]
Antworten
V12: Array + automatisches speichern+ automatisches laden - Engineering Student 18. April 2015 um 18:21:04
Re: Array + automatisches speichern+ automatisches laden - Nico 18. April 2015 um 18:46:20
Re: Array + automatisches speichern+ automatisches laden - Engineering Student 18. April 2015 um 19:52:14
Re: Array + automatisches speichern+ automatisches laden - Nico 18. April 2015 um 20:02:08
Re: Array + automatisches speichern+ automatisches laden - Engineering Student 18. April 2015 um 20:13:43
Re: Array + automatisches speichern+ automatisches laden - Nico 18. April 2015 um 20:33:52
Re: Array + automatisches speichern+ automatisches laden - Engineering Student 18. April 2015 um 20:44:12
Re: Array + automatisches speichern+ automatisches laden - Nico 18. April 2015 um 21:17:23
Re: Array + automatisches speichern+ automatisches laden - Engineering Student 19. April 2015 um 02:28:38

Ihre Antwort
(Nick-)Name   Wichtige Informationen zur Namensangabe
E-Mail (opt.)  Wichtige Informationen zur Angabe einer eMail-Adresse
Thema   Wichtige Informationen zur Angabe eines Themas
Betrifft (IDE)  VB 2012
Ihre Antwort
Smilies
Mehr...
FettKursivUnterstrichen   Übersicht der Tipp-KürzelÜbersicht der Projekt-KürzelÜbersicht der Bücher-Kürzel 
Homepage
Titel
Root-Smilies              
             
             
[ Zurück zum VB.Net-Forum | Forum-Archiv | Forum-Hilfe | Chat ]

Zum Seitenanfang

Startseite | VB-/VBA-Tipps | Projekte | Tutorials | API-Referenz | Komponenten | Bücherecke | Gewinnspiele | VB.Net | VB/VBA-Forum | DirectX | DirectX-Forum | Chat | Ausschreibungen | Links | Suchen | Stichwortverzeichnis | Feedback | Impressum

Seite empfehlen Bug-Report
Letzte Aktualisierung: Sonntag, 13. Dezember 2015