Web development India freelance website designer developer India SEO

VB5, VB6
When you put the API calls in a BAS module, they're easy to use with any form. You can
also import the module into other projects.

Option Explicit

Private Declare Function SetWindowLong Lib _
"user32" Alias "SetWindowLongA" (ByVal hWnd As _
Long, ByVal nIndex As Long, ByVal dwNewLong As _
Long) As Long

Private Declare Function GetWindowLong Lib _
"user32" Alias "GetWindowLongA" (ByVal hWnd As _
Long, ByVal nIndex As Long) As Long

Private Const GWL_STYLE = (-16)
Public ES As Long

Private Declare Function SendMessageAsLong Lib _
"user32" Alias "SendMessageA" (ByVal hWnd As _
Long, ByVal wMsg As Long, ByVal wParam As _
Long, ByVal lParam As Long) As Long

Private Declare Function SendMessageAsString Lib _
"user32" Alias "SendMessageA" (ByVal hWnd As _
Long, ByVal wMsg As Long, ByVal wParam As _
Long, ByVal lParam As String) As Long

Private Const Max_Chars_Per_Line = 80

Private Const EM_GETLINE = &HC4
Private Const EM_GETLINECOUNT = &HBA
Private Const EM_LINEFROMCHAR = &HC9
Private Const EM_LINELENGTH = &HC1
Private Const EM_UNDO = &HC7
Private Const ES_LOWERCASE = &H10&
Private Const ES_UPPERCASE = &H8&

Public Retn As Long

Public Function GetLineCount (Source As TextBox) _
As Long
GetLineCount = SendMessageAsLong(Source.hWnd, _
EM_GETLINECOUNT, 0, 0)
End Function

Public Function GetLineLength (Source As TextBox, _
LineNum As Long) As Long
GetLineLength = SendMessageAsLong(Source.hWnd, _
EM_LINELENGTH, LineNum, 0)
End Function

Public Function GetCurrentLineNumber (Source As _
TextBox) As Long
GetCurrentLineNumber = SendMessageAsLong _
(Source.hWnd, EM_LINEFROMCHAR, -1, 0)
End Function

Public Function GetLine (Source As TextBox, _
LineNumber As Long) As String
Dim ByteLo As Byte
Dim ByteHi As Byte
Dim Buffer As String
Dim ReturnedSize As Long
ByteLo = Max_Chars_Per_Line And (255)
ByteHi = Int(Max_Chars_Per_Line / 256)
Buffer = Chr$(ByteLo) + Chr$(ByteHi) + _
Space$(Max_Chars_Per_Line - 2)
ReturnedSize = SendMessageAsString _
(Source.hWnd, EM_GETLINE, LineNumber, Buffer)
GetLine = Left$(Buffer, ReturnedSize)
End Function

Public Function Undo (Source As TextBox) As Long
Undo = SendMessageAsLong(Source.hWnd, EM_UNDO, _
0, 0)
End Function

Public Sub GetES(Source As TextBox)
ES = GetWindowLong(Source.hWnd, GWL_STYLE)
End Sub

Public Function LowerCase (Source As TextBox) _
As Long
LowerCase = SetWindowLong(Source.hWnd, _
GWL_STYLE, ES Or ES_LOWERCASE)
End Function

Public Function UpperCase (Source As TextBox) _
As Long
UpperCase = SetWindowLong(Source.hWnd, _
GWL_STYLE, ES Or ES_UPPERCASE)
End Function

Public Function RestoreMixedCase (Source As _
TextBox) As Long
RestoreMixedCase = SetWindowLong(Source.hWnd, _
GWL_STYLE, ES)
'presume ES is correct
End Function
Put API Controls in BAS Module

151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300

India web developer web development India | Freelance web development ecommerce web developer | Prayagasoft - web designer India, Ecommerce developer india, Ecommerce design