vb로 된 오른쪽 정렬입니다.
이것을 델파이로 옮겨주세요....
Public Sub RightAccept(txtBox As Object)
Dim sValue As String
Dim bWidth As Long, sWidth As Long, bCount As Integer
txtBox.Parent.Font.Name = txtBox.Font.Name
txtBox.Parent.Font.Bold = txtBox.Font.Bold
txtBox.Parent.Font.Size = txtBox.Font.Size
sValue = Trim(txtBox.Text)
If Len(sValue) = 1 And sValue = "-" Then
Else
If InStr(sValue, ".") = 0 Then
sValue = Format(sValue, "###,##0")
End If
End If
bWidth = txtBox.Parent.TextWidth(Space(2)) - txtBox.Parent.TextWidth(Space(1))
sWidth = txtBox.Parent.TextWidth(sValue)
bCount = Fix((txtBox.Width - sWidth) / bWidth) - 1
If bCount > 0 Then
txtBox.Text = Space(bCount) + sValue
Else
sValue = Format(txtBox.Text, "######") 'CStr(CDbl(txtBox.Text))
sWidth = txtBox.Parent.TextWidth(sValue)
bCount = Fix((txtBox.Width - sWidth) / bWidth) - 1
If bCount > 0 Then
txtBox.Text = Space(bCount) + sValue
End If
End If
txtBox.SelStart = Len(txtBox.Text)
End Sub
> vb로 된 오른쪽 정렬입니다.
> 이것을 델파이로 옮겨주세요....
비베를 잘몰라서 제대로 이해한건지 모르겠지만.. 델파이의 포맷펑션
쓰시면 될것같은데요.
예)
MyStr := 'Hello';
MyStr := format('%10s',[MyStr]);
Result = ' Hello';