Thursday, May 21, 2015

How to Join an Array of Strings into a single String in VBA

VBA Join Function
The VBA 'Join' Function joins the Substrings contained in an array, and returns a String by Concatenating the  Substrings separated by a specified delimiter.

Syntax :
StringName = join(Array Input, Delimiter)

Here , Array Input is the array that you want to place into a string.

Delimiter is an optional parameter that indicates what you want to place between elements are added to the string. By default this parameter is set to "".

Sub Split_Store_In_Array()

Dim MyStr(6) As String

'Array Input as follows
MyStr(0) = "This"
MyStr(1) = "Is"
MyStr(2) = "What"
MyStr(3) = "I"
MyStr(4) = "Want"
MyStr(5) = "To"
MyStr(6) = "Store"


'Concatenating/Joining all Arrary Values so as to form a single String
Conc_Str = Join(MyStr, "_")

MsgBox Conc_Str

End Sub

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose, we have a sample Sales data, which is stored with Monthly Snaps...

Popular Posts from this Blog