Programming Notes


This page contains random programming notes that might be useful.

Visual Basic VB.Net, and C++ for Arduino.


Counting the number of lines in a multiline TextBox - VB.Net

This code was posted by Gadget at

Public Class AnyClass

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lparam As Integer) As Integer
Private Const EM_GETLINECOUNT As Integer = &HBA '''which is 186

Private Sub AnyProcedure()
Call TextBoxLineCount()
End Sub

Private Sub TextBoxLineCount()
Dim LineCount As Integer
Dim Message As String
LineCount = SendMessage(TextBox1.Handle.ToInt32, EM_GETLINECOUNT,0,0)
Message ="Line Count = " & LineCount.ToString
MsgBox (Message, vbOKOnly,"title")
End Sub

End Class


Valid HTML 4.01 Transitional