Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21238

Help splitting a string!

$
0
0
Hi guys,

I'm fairly new to visual basic but I'm having a bit of trouble here trying to split a string.

Basically I've got a long piece of text, for example a string containing the following formula...

" 250*10*15 + 10*100 - 100*55 - X*1000 - 1000*100*99 + 500*60*700 "

I'm trying to print this on to my form, however the string is too long for the form and I would like to be able to process this string and display it on 2 lines instead of one so that the whole formula is visible.

Basically i need a piece of code that will search through the string looking for the last appropriate point to split it and then be able to print the 2 seperate strings onto the form. I have no trouble printing 2 seperate strings. The main problem I'm having is trying to find where to split the string. I need to split the string at the last possible "+" or "-" sign so that the first string will fit fully on the page and the 2nd string can be printed underneath this.

So for example the 2 strings should look a bit like this after it has been split...

" 250*10*15 + 10*100 - 100*55 - X*1000 "
" - 1000*100*99 + 500*60*700 "


Can anyone help me? Sorry its a bit long winded but I tried to describe the problem as best i could.

Thanks.

Viewing all articles
Browse latest Browse all 21238

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>