Home > Software engineering >  Vb centered character problem
Vb centered character problem

Time:11-02

 'is coordinates the following below is the code, the desired effect of characters in the middle of the two calibration, 
'now the question is: 1, not center; 2, to the number of & gt; After 14, little one character at a time; 3, to 18, the most is not on the scale on the left picture,

Option Explicit

Private Sub Command1_Click ()
Dim As Single, I MyValue As Single
Dim x As Double (100000), y (1000000) As a Double
Picture1. Cls
Picture1. AutoRedraw=True
Picture1. DrawWidth=2
MyValue=https://bbs.csdn.net/topics/InputBox (" please enter the coordinates calibration number: ")

Picture1. Scale (500, 3200) - (5200-500) '//(X, Y) in the upper left corner, and the lower right corner (X, Y)
Picture1. Line (0, 0) - (5000, 0) '/draw/X
Picture1. Line (0, 0) - (0, 3000) '//draw Y

Do
I=I + 5000/MyValue
If I & gt; 5000 Then the Exit Do
X (I)=I
Y (I)=0
Picture1. Line (x (I), y (I) - 50) - (x (I), y (I))//'painting on the x axis calibration
Picture1. CurrentX=I - (5000/MyValue)/2 - TextWidth (" 2012 ")/2
Picture1. CurrentY=50
-Picture1. Print "2012"
The Print I, TextWidth (" 2012 "), I/2 - TextWidth (" 2012 ")/2
Loop
End Sub

CodePudding user response:

Print the x1, x2 between the play:

Currentx=(x1 + x2 - textwidth (s))/2

CodePudding user response:

 Picture1. CurrentX=I - (5000/MyValue)/2 - TextWidth (" 2012 ")/2 
'the prefix, omitted TextWidth above is equal to'
Picture1. CurrentX=I - (5000/MyValue)/2 - Me. TextWidth (" 2012 ")/2
'but the Picture1 use custom coordinates, you use the form coordinate calculation the width of the basic unit and the width of the Picture1 coordinates,'
'right should be as follows:'
Picture1. CurrentX=I - (5000/MyValue)/2 - Picture1. TextWidth (" 2012 ")/2

CodePudding user response:

Tiger_Zhao

I tried, still won't do, more not center ah,,,

I put all the code to this, you try,


 Option Explicit 

Private Sub Command1_Click ()
Dim I As Single, MyValue As Single, PianYi As Single
Dim x As Double (100000), y (1000000) As a Double
Picture1. Cls
Picture1. AutoRedraw=True
Picture1. DrawWidth=2
On Error GoTo 100
MyValue=https://bbs.csdn.net/topics/InputBox (" please enter the coordinates calibration number: ")
Picture1. FontSize=18
Picture1. Scale (500, 3200) - (5200-800) '//(X, Y) in the upper left corner, and the lower right corner (X, Y)
Picture1. Line (0, 0) - (5000, 0) '/draw/X
Picture1. Line (0, 0) - (0, 3000) '//draw Y
Picture1. Line (0-100) - (0, 0) '//draw the X axis calibration first
PianYi=100
For I=1 To MyValue

X (I)=I * 5000/MyValue
Y (I)=0
Picture1. Line (x (I), y (I) - PianYi) - (x (I), y (I))//'painting on the x axis calibration
Picture1. CurrentX=x (I) - (5000/MyValue)/2 - Picture1. TextWidth (I)/2
The Picture1. Print I
TextWidth Print x (I), (I), x (I)/2 - TextWidth (I)/2
Next I
100
End Sub

CodePudding user response:

 'Picture1. Print the I & lt; - printing digital prefixing Spaces, when they want to use the string to print '
Picture1. Print CStr (I)
  • Related