Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have a DataGrid that a user will past a list of characters into and I would like to Grid to remove all but the First 3 Characters, for example, the user will past this,

EAP 29240
ERX 23925
ETX 23647
LPP 7996
LPR 16470-16472 item 34500
LQL 4386-4387
OSQ 23813-23816
PAF 6245
PRL 6584

and I want the result to be this,
EAP
ERX
ETX
LPP
LPR
LQL
OSQ
PAF
PRL

Thanks in advance

What I have tried:

I've been trying something like this but it doesnt work

Dim mystring As String = Me.TextBox1.Text
mystring.Length - 3
Posted
Updated 18-Mar-21 12:10pm
v2
Comments
[no name] 18-Mar-21 15:24pm    
Use Substring(0,3).

https://docs.microsoft.com/en-us/dotnet/api/system.string.substring?view=net-5.0#System_String_Substring_System_Int32_System_Int32_

1 solution

Dim mystring As String = Left(Me.TextBox1.Text, 3)
 
Share this answer
 
Comments
Maciej Los 19-Mar-21 4:15am    
5ed!
I'd avoid of using old vb functions, such as Left. As Gerry Schmitz suggested, it should be Substring.
Dim mystring As String = Me.TextBox1.Text.Substring(0, 3)
gacar 19-Mar-21 7:32am    
Yes, maybe right but VB.NET already a dying language, I don't think this will change the outcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900