dcsimg
Results 1 to 4 of 4

Thread: [RESOLVED] saving all textboxes

  1. #1

    Thread Starter
    Hyperactive Member Rattled_Cage's Avatar
    Join Date
    Dec 2005
    Posts
    315

    Resolved [RESOLVED] saving all textboxes

    hi
    on my form it creates some html pages in a textbox at runtime
    this looks on forms and lists all known textboxes
    i just need to save them all
    its finding them ok

    Code:
    Dim lines() As String, i As Integer
    Dim txt_Name As String
    Dim Txt As Control
    For Each Txt In Controls
    If TypeOf Txt Is TextBox Then
    Open App.Path & "\SvrHtml\" & Txt.Name & ".html" For Output As #1
     lines() = Split(Txt.Name , vbCrLf)    ''' wont work but any other textbox "name" without the .text will
    For i = 0 To UBound(lines)
    Print #1, lines(i)
    Next
      Close #1
    End If
    Next

    if i change the Txt.Name to Text1 etc it saves that box ok

    a bit confused where im going wrong

  2. #2
    Hyperactive Member
    Join Date
    Aug 2006
    Location
    TeXaS
    Posts
    497

    Re: saving all textboxes

    Text1 defaults to Text1.Text. a quick look makes me think you should change the code to lines() = Split(Txt.Text , vbCrLf)
    and i see you declared txt_Name, but you dont seem to use it.

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,079

    Re: saving all textboxes

    You should not be using txt.Name there as all that would return would be the name of the textbox not the content of it.

    You should use either just txt or txt.text there, assuming of course you want the text from the textbox.

  4. #4

    Thread Starter
    Hyperactive Member Rattled_Cage's Avatar
    Join Date
    Dec 2005
    Posts
    315

    Cool Re: saving all textboxes

    thanks for that its been anoying me for ages
    works as

    Code:
     lines() = Split(Txt.Text, vbCrLf)

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width