Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27472

Faster/cleaner way to calculate width/Left of textbox depending on number

$
0
0
Hey all i am currently looking for a way to calculate the width & left position of MAX 12 txtboxes on my report form. The height will always be 0.206 as well as top will always be 0.

This is what the code looks like with 12 (max) txtboxes:
Code:

    txtData1.Width = 0.7
    txtData1.Left = 0

    txtData2.Width = 0.7
    txtData2.Left = 0.708

    txtData3.Width = 0.7
    txtData3.Left = 1.416

    txtData4.Width = 0.7
    txtData4.Left = 2.124

    txtData5.Width = 0.7
    txtData5.Left = 2.832

    txtData6.Width = 0.7
    txtData6.Left = 3.54

    txtData7.Width = 0.7
    txtData7.Left = 4.248

    txtData8.Width = 0.7
    txtData8.Left = 4.956

    txtData9.Width = 0.7
    txtData9.Left = 5.664

    txtData10.Width = 0.7
    txtData10.Left = 6.372

    txtData11.Width = 0.7
    txtData11.Left = 7.08

    txtData12.Width = 0.7
    txtData12.Left = 7.788

According to my calculations (which i love math...math just doesn't love me :) ) the total width would be 8.4 in and the total left would be 7.788 in. The sheet is 8.5 in wide (landscape view).



So now the hard part comes into play. For 11 boxes, the width would go up a little and the left position would also go up to accommodation the extra space not having the 12th box anymore.

I am trying to find a nice way of doing this with minimal code since i know i can do the same as above for each level (12 to 2 textboxes) but that would be a lot of code.

So any help with calculating the remaining 11-2 txtboxes would be a big help! :o)

Viewing all articles
Browse latest Browse all 27472

Trending Articles



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