How would you go about making text link to the web?? Im trying to make a program where you can store web pages. Also when i close this program down, how would I make it so that it keeps all of the information added during that sesion?
-Steve
Printable View
How would you go about making text link to the web?? Im trying to make a program where you can store web pages. Also when i close this program down, how would I make it so that it keeps all of the information added during that sesion?
-Steve
With regard to the second point, you would either have to write the entered data to the registry or to a text file before shutting down the program.
ok, that sounds resonable. How would i go about writing to a text file?
I think you should use a listbox to store the Web addresses and use this code to save and load them to and from the listbox.
And you can have it so that when the user double clicks on the listbox, it will open the default browser and go to that site.Code:Public Sub List_Load(TheList As ListBox, FileName As String)
On Error Resume Next
Dim TheContents As String
Dim fFile As Integer
fFile = FreeFile
Open FileName For Input As fFile
Do
Line Input #fFile, TheContents$
TheList.Additem TheContents$
Loop Until EOF(fFile)
Close fFile
End Sub
Public Sub List_Save(TheList As ListBox, FileName As String)
On Error Resume Next
Dim Save As Long
Dim fFile As Integer
fFile = FreeFile
Open FileName For Append As fFile
For Save = 0 To TheList.ListCount - 1
Print #fFile, TheList.List(Save)
Next Save
Close fFile
End Sub
Code: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
Public Const SW_SHOWNORMAL = 1
Private Sub List1_DblClick()
ShellExecute Me.hWnd, vbNullString, List1, vbNullString, "c:\", SW_SHOWNORMAL
End Sub
You could do this one of two ways:
a sequential access file:
or random access (like an excel spreadsheet)Code:'this assumes your data is stored in an array, but it doesn't have to be.
dim datastored(100) as string
dim path as string
dim i as integer
path = app.path +"\data\stored.txt"
open path for output as #1
for i = 1 to 100
print #1, datastored(i)
close #1
If you didn't understand them, there are turorials in the files/directories section right here on vbworld.Code:dim datastored(100) as string
dim path as string
dim i as integer
path = app.path +"\data\stored.txt"
open path for random as #1
for i = 1 to 100
put #1, i, datastored(i)
close #1