PDA

View Full Version : [vb6] Help with aligning HTML to output file properly.


xyr0x
12-10-2007, 10:53 AM
Basically, my only problem here is with the "iframecode" string, and getting the meta-httpequiv-refresh to work to create an html file that will then be outputted to a folder within CurDir EX: \Websites\website.html

However, for some reason I am getting arguments that an Object must be Required. Can anybody help me? Thanks in advance, the code is below.

Dim filename As String
Dim folder As String
Dim i As Integer
Dim iframecode As String
Dim path As String
Dim present As String

txtWebsite.Enabled = False
txtCons.Enabled = False
cmdStart.Enabled = False

If txtCons.Text > 10000 Then
txtCons.Text = 10000
MsgBox ("The max connections at once is 10000")
Else
Call NoFunc
End If

folder = "\Websites\"
present = Dir(CurDir & folder, vbDirectory)
If present = "" Then
MkDir CurDir & folder
Else
End If

For i = 1 To Int(txtCons.Text)

iframecode = iframecode & "<meta http-equiv=" & Chr(34) & "REFRESH" & Chr(34) & Chr(34) & "content=" & Chr(34) & "5;url=" & Text1.Text & Chr(34) & ">" & "</HEAD>" & "<iframe src=" & Chr(34) & "http://" & txtWebsite.Text & Chr(34) & " height=" & Chr(34) & "5" & Chr(34) & " width=" & Chr(34) & "5" & Chr(34) & ">" & "</iframe>"

Next i
filename = App.path & "\Websites\" & txtWebsite.Text & ".html"

Open filename For Output As #1
Print #1, "<HTML>", "<BODY>", iframecode, "</BODY>", "</HTML>"
Close #1

wb1.Navigate filename
txtMessage.Caption = "Connections: " & txtCons.Text & vbCrLf & "To: " & txtWebsite.Text
txtWebsite.Enabled = True
txtCons.Enabled = True
cmdStart.Enabled = True
End Sub

xyr0x

DaNuKa_SAN
05-05-2008, 07:53 AM
You haven't opened the file as an object first to which you want to output unless I'm mistaken.

I believe you should have something like this before writing to the file.


Dim fso As FileSystemObject
Dim filename As File

Set fso = New FileSystemObject

'Creates a FileObject
Set filename = fso.GetFile("<Your HTML file>")


Only thing I can think of off the bat seeing as it's demanding an object as an argument.

also you may want to For Append instead of For Output...

Hope this helps.