Results 1 to 8 of 8

Thread: Vb > Html

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    4

    Vb > Html

    Can someone shoot me to a good tutorial on how to make your program take information from it, and slip it into HTML code?

    This is for VB6
    Last edited by Leomarth; Jun 14th, 2006 at 04:27 PM. Reason: add line

  2. #2
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Vb > Html

    Do you want to send something from a VB program to a webpage ..? Or the other way around ..?

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    4

    Re: Vb > Html

    I want to take information that my users generate in a program, and display it in a html file once complete.

  4. #4
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Vb > Html

    so sounds like you just want to create a html file with the data they enter then display it to them ..

    If so basically you just create the html page as you would a text file .. ofcourse enter in the HTML tags etc .. you will need to know how you want it to look and design that part of it ..

    Then Shell the page to them ..

    Is it the HTML stuff you are having issues with ..?

    Rory

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    4

    Re: Vb > Html

    No. But, when I put text to a .txt file, it puts quotes around it. For instance, when I put a persons name to a text file, I get this output ---> "George Bush"

    Now, I know that HTML tags won't work if they're formatted with quotes around them.

    I'm using the WRITE #1, mytext format. Is there a better way without using FSO?

  6. #6
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Vb > Html

    You shouldnt be getting quotes around them unless you are putting them there ..

    Here are some things to test with as far as reading and writing to text files ..

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3.     Dim sText As String
    4.     Dim sFile As String
    5.     Dim sArray() As String
    6.     Dim iLine As Integer
    7.    
    8.     sFile = App.Path & "\myfile.txt"
    9.    
    10.     '// FILE EXISTS
    11.     Debug.Print "File Exists: " & DoesFileExist(sFile)
    12.        
    13.     '// CREATE FILE
    14.     If Not DoesFileExist(sFile) Then
    15.         WriteFile sFile, Now
    16.         Debug.Print "New File Created"
    17.     End If
    18.    
    19.     '// UPDATE FILE
    20.     If DoesFileExist(sFile) Then
    21.         sText = ReadFile(sFile)
    22.         Debug.Print "File Text: " & Replace(sText, vbCrLf, vbCrLf & "File Text: ")
    23.         UpdateFile sFile, vbCrLf & Now
    24.         Debug.Print "Updated Old File"
    25.     End If
    26.    
    27.     '// LOOP THROUGH LINES
    28.     sText = ReadFile(sFile)
    29.     If Len(sText) Then
    30.         sArray = Split(sText, vbCrLf)
    31.         For iLine = 0 To UBound(sArray)
    32.             Debug.Print "File Array (" & iLine & "): " & sArray(iLine)
    33.         Next iLine
    34.     End If
    35.    
    36.     '// DELETE FILE
    37.     If DeleteFile(sFile) Then
    38.         Debug.Print "Deleted File"
    39.     End If
    40.    
    41.     Debug.Print ""
    42.  
    43. End Sub
    44.  
    45. '// READ ALL FROM TEXT FILE
    46. Public Function ReadFile(ByVal Filename As String) As _
    47.     String
    48.     Dim iFile As Integer
    49.     On Error Resume Next
    50.     iFile = FreeFile
    51.     Open Filename For Input As #iFile
    52.         ReadFile = Trim$(Input$(LOF(iFile), #iFile))
    53.     If iFile > 0 Then Close iFile
    54. End Function
    55.  
    56. '// WRITE TO TEXT FILE
    57. Public Function WriteFile(ByVal Filename As String, _
    58.     ByVal Filetext As String) As Boolean
    59.     Dim iFile As Integer
    60.     On Error Resume Next
    61.     iFile = FreeFile
    62.     Open Filename For Output As #iFile
    63.         Print #iFile, Filetext;
    64.     If iFile > 0 Then Close iFile
    65.     If Err = 0 Then WriteFile = True
    66. End Function
    67.  
    68. '// APPEND TO TEXT FILE
    69. Public Function UpdateFile(ByVal Filename As String, _
    70.     ByVal Filetext As String) As Boolean
    71.     Dim iFile As Integer
    72.     On Error Resume Next
    73.     iFile = FreeFile
    74.     Open Filename For Append As #iFile
    75.         Print #iFile, Filetext;
    76.     If iFile > 0 Then Close iFile
    77.     If Err = 0 Then UpdateFile = True
    78. End Function
    79.  
    80. '// DELETE TEXT FILE
    81. Public Function DeleteFile(ByVal Filename As String) _
    82.     As Boolean
    83.     On Error Resume Next
    84.     Kill Filename
    85.     If Err = 0 Then DeleteFile = True
    86. End Function
    87.  
    88. '// CHECK FILE EXISTS FSO METHOD
    89. Public Function DoesFileExist(ByVal Filename As String) As _
    90.     Boolean
    91.     Dim objFso 'As FileSystemObject (reference)
    92.     On Error Resume Next
    93.     Set objFso = CreateObject("Scripting.FileSystemObject")
    94.     If (objFso.FileExists(Filename)) Then
    95.        DoesFileExist = True
    96.     End If
    97.     Set objFso = Nothing
    98. End Function

  7. #7

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    4

    Re: Vb > Html

    Ok, when the computer gets to "DoesFileExist", it tells me Sub or Function not Defined.

  8. #8
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: Vb > Html

    Are you sure you included it in the form ..?

    VB Code:
    1. '// CHECK FILE EXISTS FSO METHOD
    2. Public Function DoesFileExist(ByVal Filename As String) As _
    3.     Boolean
    4.     Dim objFso 'As FileSystemObject (reference)
    5.     On Error Resume Next
    6.     Set objFso = CreateObject("Scripting.FileSystemObject")
    7.     If (objFso.FileExists(Filename)) Then
    8.        DoesFileExist = True
    9.     End If
    10.     Set objFso = Nothing
    11. End Function

    Can you post your code?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width