|
-
Sep 19th, 2000, 02:45 PM
#1
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
-
Sep 19th, 2000, 02:47 PM
#2
Hyperactive Member
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.
-
Sep 19th, 2000, 02:50 PM
#3
ok, that sounds resonable. How would i go about writing to a text file?
-
Sep 19th, 2000, 02:59 PM
#4
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.
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
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:
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
-
Sep 19th, 2000, 02:59 PM
#5
Hyperactive Member
You could do this one of two ways:
a sequential access file:
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
or random access (like an excel spreadsheet)
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
If you didn't understand them, there are turorials in the files/directories section right here on vbworld.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|