excel vba - fetch substring from string between two special character like ^abc^ in VBA -


i have form 2 textboxes , command button. want in vba copy part of text text1 text3 when cmd button pressed. example part of string #&!4848484848484 ^totot/euhen^ gjrlsmdkkkd in text1 copied text3 totot/euhen, there no fixed numbers or places before, somehow has predicated on ^ symbol. i.e. text3 = whatever between ^ , ^.

the easiest way use split function, add below code user form:

private sub commandbutton1_click()     dim atmp     atmp = split(textbox1.value, "^", 3)     if ubound(atmp) = 2 textbox3.value = atmp(1) end sub 

that code splits source text ^ character , puts parts in array. array length limited 3 elements, having indexes 0..2. sample string #&!4848484848484 ^totot/euhen^ gjrlsmdkkkd splited #&!4848484848484, totot/euhen, gjrlsmdkkkd array. array checked if has 3 elements, means 2 ^ chars found, text capture located in 2nd element.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo