vba - Microsoft Access - Insert part of a string up until a specific character -


i'll keep simple:

i have 3 textboxes , button. textbox1 used user input

button1 pressed , gives textbox2 , textbox3 specific value based on string textbox1.

for example- user input: 'hello & welcome everybody'

*press button

textbox2.value = 'hello'

textbox3.value = 'welcome'

so basically, how go selecting part of string until character?

and also, how go selecting part of string between character/words (in case, between '&' , 'everybody'

i know dim 2 variables strings store them, set value of textboxes equal variables. don't know code use obtain specific parts of string in first place. ideas?

use split function split string on & character, returning array of resulting substring pieces.

here example immediate window:

struserinput = "hello & welcome everybody" varpieces = split(struserinput, "&") debug.print trim(varpieces(0)) hello debug.print trim(varpieces(1)) welcome 

since want "welcome" instead of "welcome everybody", can split() again:

debug.print split(trim(varpieces(1)), " ")(0) welcome 

however looks simpler split() on spaces in first place , take first , third items array. (thanks, johnny bones!):

varpieces = split(struserinput, " ") ? varpieces(0) hello ? varpieces(2) welcome 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -