Results 1 to 5 of 5

Thread: string variables

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    15
    what is a good way to split a string variable into
    several other variables, or seperate lines by number of characters?

    Thanks
    [email protected]

    In the near future the common person will think that Microsoft developed the first operating system, and invented the internet in collaboration with Al Gore.

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    [code]
    Split
    Returns a zero-based, one-dimensional array containing a specified number of substrings.

    Syntax
    Split(expression[, delimiter[, count[, compare]]])

    The Split syntax has these parts:

    Part Description
    expression Required. String expression containing substrings and delimiters. If expression is a zero-length string, Split returns an empty array, that is, an array with no elements and no data.
    delimiter Optional. String character used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned.
    count Optional. Number of substrings to be returned; -1 indicates that all substrings are returned.
    compare Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values.


    Settings
    The compare argument can have the following values:

    Constant Value Description
    vbBinaryCompare 0 Perform a binary comparison.
    vbTextCompare 1 Perform a textual comparison.
    vbDatabaseCompare 2 Perform a comparison based on information contained in the database where the comparison is to be performed.
    [/ode]


    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Guest
    Use the Split() function
    Code:
    Dim MyString As String
    MyString = "One,Two,Three,Four,Five"
    
    'Split whenever there is a comma
    MyArray = Split(MyString, ",")
    
    'Display each element
    For I = LBound(MyArray) To UBound(MyArray)
       Print MyArray(I)
    Next I

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    15

    call me crazy

    so if I had a variable [penguin] and

    penguin = "even if the attacker cannnot read the contents of your encrypted messages, he may be able to infer at least some useful information."
    then I could

    Split (penguin, Char(13), 25)
    (trying to split it every 25 characters with a carriage return)

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You would have to do it this way then:
    Code:
     dim n as integer,temp as string
     For n=1 to len(penguin) step 25
      if n>1 then temp=temp & vbcrlf
      temp=temp & mid(penguin,n,25)
     next n
     penguin=temp
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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