Hi,
I'm wanting to find the width of a text box and if it's longer than say 200 pixels, decrement the font size (points) by one until the text box width is less than 200 pixels. I'm guessing I'm going to need some form of loop here but I'm having problems with this.
I've not included all of my code just the important parts.
TextItem.Size = 50
TextItem.Kind = 2 (to allow me to find the width)
Dim TextWidth = TextItem.Width
Now my thoughts for the loop are...
While TextWidth > 200
TextItem.Size -= 1
TextWidth = TextItem.Width
End While
I'm not the best programmer so don't know if that loop is completely correct but my idea behind it is that while the text box width is greater than 200, decrease the font size by one, find the new text box width then if this is still greater than 200, repeat the process until it's less.
The part i seem to be having a problem with is the "TextWidth = TextItem.Width" inside the while loop. From testing I know that when the text box width is greater than 200 pixels, it correctly enters the loop, decreases the font size, BUT I can't seem to get it to find the new width of the text box. Instead it appears to be still using the original value for width and hence never ending the loop.
Can somebody please point me in the direction of where I'm going wrong?
Thanks in advance.