Passing Variable length Space Characters to Variables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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...
 
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)
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top