Results 1 to 2 of 2

Thread: string manipulation help

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2010
    Posts
    2

    string manipulation help

    i want to edit text files in vb6.
    but i have a problem..
    i can't hide the return back the ampersand on the text file when i need to save it.

    i don't know how to return back the deleted ampersand when i saved the text file.
    help me


    here's my code

    Private Sub Command2_Click()
    Dim cont, cont1, cont2 As String
    Dim jak, jak2 As String

    Dim pos, ctr As Integer
    cont = RichTextBox1.Text
    cont1 = RichTextBox1.Text
    cont2 = "="
    pos = InStr(cont, cont2)

    jak1 = Mid(cont1, pos + 1)
    jak2 = Left(jak, Len(jak) - 1)
    MsgBox jak2
    End Sub

  2. #2
    Fanatic Member
    Join Date
    Mar 2009
    Posts
    804

    Re: string manipulation help

    Your post/code is confusing. You say you are looking for the ampersand, '&' character, yet
    your code searches for the equals, '=' character. I assume you are trying to save
    only the text up to, but not including, the "=" character. If so, it looks like jak2 does it.

    By the way, this line

    Dim cont, cont1, cont2 As String

    may not do what you think it does. Only cont2 will be declared as String, while the
    others will be Variants. Assuming you want them all to be strings, you need

    Dim cont As String, cont1 As String, cont2 As String

    Also you have declared jak & jak2 but your code uses jak1 & jak2.

    Also, I'm not sure why you have cont and cont1, which appear to get the same content.

    If your code compiles without error, you must not be using Option Explicit, which is highly
    recommended in helping to find these types of errors. You can tell VB to always
    put the Option Explicit declaration at the top of all new code modules if you select
    Tools|Options|Editor and check Require Variable Declaration.

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