Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I've read few articles on internet but i don't understand. In vb6 converting number like
15823581427163588888
into
15823-58142-71635-88888
is simply using
VB
Format("00000-00000-00000-00000")
.

This is my code:
VB
ItemsDataGridView.Rows(e.RowIndex).Cells(1).FormattedValue.ToString

I'm getting a value from datagridview, it worked but u tried using this:
VB
Format("00000-00000-00000-00000", ItemsDataGridView.Rows(e.RowIndex).Cells(1).FormattedValue.ToString)

and this
VB
Format("#####-#####-######-#####", ItemsDataGridView.Rows(e.RowIndex).Cells(1).FormattedValue.ToString)

none of that worked, instead of displaying
15823-58142-71635-88888, 15823581427163588888 
displayed

Thanks :D
Posted
Updated 21-Jul-15 5:25am
v2

1 solution

Try taking off the ToString call, and use the Value property instead of the FormattedValue:
VB.NET
Format("00000-00000-00000-00000", ItemsDataGridView.Rows(e.RowIndex).Cells(1).Value)

You could also use the String.Format method from the BCL, instead of the VB-specific Format function:
VB.NET
String.Format("{0:00000-00000-00000-00000}", ItemsDataGridView.Rows(e.RowIndex).Cells(1).Value)
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 21-Jul-15 13:16pm    
Ha-ha, good catch, a 5.
—SA

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