+ Reply to Thread
Results 1 to 6 of 6

Passing Variable length Space Characters to Variables

  1. #1
    ExcelMonkey
    Guest

    Passing Variable length Space Characters to Variables

    How do you pass variable length space to a variable. If I want to pass a
    space cwith three spaces, I can do it manually by going:

    Var = "---" (dashes representing spaces)

    But what if the space width is variable in length? In this example I need
    to pass the number three to a variable and then use this to define the space
    between my quotes that get passed to my Var.

    Thanks

  2. #2
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187
    var=String(3, "-")

    regards

  3. #3
    Jim Thomlinson
    Guest

    RE: Passing Variable length Space Characters to Variables

    There is a function called string which takes two arguments. The number of
    charachters and the character to repeat.

    dim myString as String

    myString = String(3, "-")
    msgbox myString 'Shows 3 dashes

    Just as a note I have always disliked the fact that String is both a data
    type and a function. Who thought of that...
    --
    HTH...

    Jim Thomlinson


    "ExcelMonkey" wrote:

    > How do you pass variable length space to a variable. If I want to pass a
    > space cwith three spaces, I can do it manually by going:
    >
    > Var = "---" (dashes representing spaces)
    >
    > But what if the space width is variable in length? In this example I need
    > to pass the number three to a variable and then use this to define the space
    > between my quotes that get passed to my Var.
    >
    > Thanks


  4. #4
    ExcelMonkey
    Guest

    RE: Passing Variable length Space Characters to Variables

    Figured it out. Thanks

    DesiredLenth = 3
    SpaceWidth = ""
    For Y = 1 To DesiredLenth
    SpaceWidth = SpaceWidth & Chr(32)
    Next
    CurrentFormulaNoFunction = Replace(CurrentFormula, AllFunctions(X),
    SpaceWidth, 1, -1, vbTextCompare)




    "ExcelMonkey" wrote:

    > How do you pass variable length space to a variable. If I want to pass a
    > space cwith three spaces, I can do it manually by going:
    >
    > Var = "---" (dashes representing spaces)
    >
    > But what if the space width is variable in length? In this example I need
    > to pass the number three to a variable and then use this to define the space
    > between my quotes that get passed to my Var.
    >
    > Thanks


  5. #5
    Robin Hammond
    Guest

    Re: Passing Variable length Space Characters to Variables

    Does this help?

    Sub Test()
    Dim strData As String
    strData = Space(50)
    Debug.Print Len(strData)
    Debug.Print strData & "x"
    End Sub

    Robin Hammond
    www.enhanceddatasystems.com

    "ExcelMonkey" <[email protected]> wrote in message
    news:[email protected]...
    > How do you pass variable length space to a variable. If I want to pass a
    > space cwith three spaces, I can do it manually by going:
    >
    > Var = "---" (dashes representing spaces)
    >
    > But what if the space width is variable in length? In this example I need
    > to pass the number three to a variable and then use this to define the
    > space
    > between my quotes that get passed to my Var.
    >
    > Thanks
    >




  6. #6
    Dana DeLouis
    Guest

    Re: Passing Variable length Space Characters to Variables

    > But what if the space width is variable in length?

    Just one example:

    Sub Demo()
    Dim n, Str
    n = 10
    Str = Space(n)
    End Sub

    --
    HTH. :>)
    Dana DeLouis
    Windows XP, Office 2003


    "ExcelMonkey" <[email protected]> wrote in message
    news:[email protected]...
    > How do you pass variable length space to a variable. If I want to pass a
    > space cwith three spaces, I can do it manually by going:
    >
    > Var = "---" (dashes representing spaces)
    >
    > But what if the space width is variable in length? In this example I need
    > to pass the number three to a variable and then use this to define the
    > space
    > between my quotes that get passed to my Var.
    >
    > Thanks




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1