I am new to VB, can anyone help me regarding the following:
I have a form, i want to divide it into 32 columns and 16 rows. Based on the requirement i want to display on the co-ordinates say (16th column,5th row) some text on the form.
Please note that we are not using mouse for this application.
Thanks for your reply . I guess it will not match my requirement. My requirement is something like this I want to display a frame(with black background) and on that i need to display the text i don't want the grid to be displayed.
The text to be dispaly can be in different positions.
You could use the Print method, but that doesn't really offer you much power in setting where to print the text onto the form, but in any case, here's an example :
Code:
Print "test"' writes the word 'test' on form
Your'e best bet would be to use the DrawText API. Copy this into a new form :
Code:
Option Explicit
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hDC As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Private Const DT_WORDBREAK = &H10
Private Sub Command1_Click()
Dim rct As RECT
Me.ScaleMode = vbPixels
With rct
.Left = 4
.Right = Me.ScaleWidth
.Top = 10
.Bottom = Me.ScaleHeight
End With
DrawText Me.hDC, "WELCOME", -1, rct, DT_WORDBREAK 'can use textbox here or whatever instead of "WELCOME"
With rct
.Left = 20
.Right = Me.ScaleWidth
.Top = 30
.Bottom = Me.ScaleHeight
End With
DrawText Me.hDC, "TO", -1, rct, DT_WORDBREAK
With rct
.Left = 40
.Right = Me.ScaleWidth
.Top = 60
.Bottom = Me.ScaleHeight
End With
DrawText Me.hDC, "FORM", -1, rct, DT_WORDBREAK
End Sub
An alternative, is to have a multi line textbox on the frame filled with spaces corresponding to the number of rows/columns required. Then you can use string manipulation to implant text into the textbox. The textbox has to be set to a non-proportional font (for instance Courier).
If you use a RTB (Rich Text Box), you can draw text at screen positions.
Originally Posted by Killa69
An alternative, is to have a multi line textbox on the frame filled with spaces corresponding to the number of rows/columns required. Then you can use string manipulation to implant text into the textbox. The textbox has to be set to a non-proportional font (for instance Courier).
See attached file for example.
OK, the lights inside my head went on now. Good work guys!
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.