vba - Putting all elements of an array variable onto their own line in a message box -


the code below fragment of macro i'm writing alert users may not have sufficient number of compatible installation equipment on order. n shortfalls (i.e., each instance of equipment item not having compatible installation equipment saved in yankees() array in elements 1 n. want prompt users message box stating "please review order ensure have sufficient compatible installation equipment- detected following shortfalls"

and below that

include each element of yankees(1 n) on separate lines in message box 2 options below "this okay, i'll submit order now" , "let me go back,i want modify order".

how can create such message box?

i have:

 msgbox "please review order ensure have sufficient compatible     installation equipment- detected following concerns" & yankee(1), vbokcancel 

currently includes first shortfall. how can include elements of yankee() , put them on own line?

this question boils down to: "how put non-blank elements of array variable onto own lines in message box prompt"?

do if rip(qbert) < k(qbert) yankee(jets) = "your order for" & s(qbert) & " contains " & k(qbert) - rip(qbert) & "     few " & g(qbert) jets = jets + 1 qbert = qbert + 1 else qbert = qbert + 1 end if loop until qbert > echo 

you can use join function:

sub test()     dim var variant      'populate dummy vector array comma-separated list:     var = split("alpha,beta,gamma,delta,epsilon", ",")      'display contents of array delimited list, use carriage return delimit:     msgbox join(var, vbcr)  end sub 

enter image description here

the above not ignore blanks. ignore blanks, per specific question, can iterate on array , test blank values. in function:

how put non-blank elements of array variable onto own lines in message box prompt

in sub, pass yankees function, like:

msgbox = getmessagetext(yankees) 

here function:

function getmessagetext(var variant) string     'assumes vector array     on error goto earlyexit      dim smsg string     dim v variant      each v in var         if not v = vbnullstring             smsg = smsg & v & vbcr         end if     next  earlyexit:     if err.number = 0         getmessagetext = smsg     else:         getmessagetext = "invalid array"     end if  end function 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -