Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
guys i need to check if a barcode number starts with 27. if it does, i need to have the first 6 digitsnof this barcode in a textbox and the rest digits in another textbox how can i do that in vb.net? any help would be appreciated
how can i use the split method to do that or regular expressions or something?
Posted
Updated 29-Nov-15 14:02pm
v2

1 solution

you do know the String type has a Substring method ?

https://msdn.microsoft.com/en-us/library/aka44szs(v=vs.110).aspx[^]

so in pseudocode (ie rough code thats not really any language except the string Substr and Remove ARE VB)

if barCodeString.Substr(0,2) == '27'
    // Put 1st 6 chars of bar code into TextBox 1
    TextBox1.Text = barCodeString.Substr(0,6)
    // Create a temporary String so as to not alter original
    String TempString = barCodeString
    // Delete the 1st 6 characters
    TempString.Remove(0,6)
    // Put the Remainder in TextBox2
    TextBox2.Text = TempString
end


Why complicate things with Regular expressions ? you just have to turn what Ive put into proper VB
 
Share this answer
 

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