Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleSet tabs in a TextBox in VB .NET
DescriptionThis example shows how to set tabs in a TextBox in VB .NET.
KeywordsTextBox, tabs, VB .NET
CategoriesControls, VB.NET
 
When the program starts, it creates an array containing the tab stops' positions. It then uses the SendMessage API function to send the TextBox the EM_SETTABSTOPS message, passing it the tab stop array.
 
Private Declare Function SendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As _
    Integer, ByVal wParam As Integer, ByRef lParam As _
    Integer) As Integer
Private Const EM_SETTABSTOPS As Integer = &HCB

Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
    e As System.EventArgs) Handles MyBase.Load
    Dim tabs() As Integer = {20, 130}

    SendMessage(TextBox1.Handle, EM_SETTABSTOPS, 2, tabs(0))

    Dim txt As String = ""
    txt &= "Bacon Burger" & vbTab & "3.00" & vbCrLf
    txt &= vbTab & "Tomato" & vbTab & "0.15" & vbCrLf
    txt &= vbTab & "Extra Cheese" & vbTab & "0.20" & vbCrLf
    txt &= "Large Fries" & vbTab & "0.99" & vbCrLf
    txt &= "Medium Softdrink" & vbTab & "1.05" & vbCrLf
    txt &= "" & vbCrLf
    txt &= "Subtotal" & vbTab & "5.39" & vbCrLf
    txt &= "Tax" & vbTab & vbTab & "0.38" & vbCrLf
    txt &= "Total" & vbTab & vbTab & "5.77" & vbCrLf
    TextBox1.Text = txt
    TextBox1.Select(0, 0)
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated