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 |
Passing Variable length Space Characters to Variables
var=String(3, "-") regards -- tony h ------------------------------------------------------------------------ tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074 View this thread: http://www.excelforum.com/showthread...hreadid=509596 |
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 |
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 |
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" wrote in message ... 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 |
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" wrote in message ... 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 |
All times are GMT +1. The time now is 09:15 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com