Using the Equivalent of Left Function in VB.NET
As VB.NET no longer supports the handy Left Function anymore, you can however, use the equivalent function code that i have created below. I have named the function as sLeft since Left conflicts with another function in VB.NET. Just copy and paste the simple codes at the bottom of your project module or form.
'---Copy and Paste this piece of code into your module or project
Public Function sLeft(ByVal iString As String, ByVal Position As Integer) As String
Return Mid(iString, 1, Position)
End Function
Now, for instance, we have a string "Spaceship" stored in a variable myStr
'--- Variable Declarations
Dim myStr As String
Dim Output as String
myStr = "Spaceship" '--- Store the word Spaceship into myStr
Output = sLeft(myStr,5) '---call sLeft function to retrieve the first 5 letters of the string
Msgbox(Output) '--- Display a messagebox
The output from the message above will be "Space"
See also Mid Function in VB.NET
See also Right Function in VB.NET
See also Left Function in VB6/Classic
See also Mid Function in VB6/Classic
See also Right Function in VB6/Classic
VB.NET : Left Function Equivalent
Posted by Fluffy | 6:06 AM | Left Function VB.NET, VB.NET | 0 comments »
Subscribe to:
Post Comments (Atom)

0 comments
Post a Comment