在VB.NET中使用格式 [英] Using format in VB.NET
本文介绍了在VB.NET中使用格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在互联网上看过几篇文章,但我不明白。在vb6中将
15823581427163588888
等数字转换为
15823-58142-71635-88888
只是使用
格式( 00000-00000-00000-00000)
。
这是我的代码:
ItemsDataGridView.Rows(e.RowIndex).Cells( 1 )。FormattedValue.ToString
我从datagridview获取一个值,但是你尝试使用它:
格式( 00000-00000-00000-00000 ,ItemsDataGridView.Rows(e.RowIndex).Cells( 1 )。FormattedValue.ToString)
and this
格式( ##### - # #### - ###### - #####,ItemsDataGridView.Rows(e.RowIndex).Cells( 1 ) .FormattedValue.ToString)
这些都没有用,而不是显示
15823-58142-71635-88888,15823581427163588888
显示
谢谢:D
解决方案
尝试取消ToString
电话,并使用Value
属性而不是FormattedValue
:
格式( 00000-00000-00000-00000,ItemsDataGridView.Rows(e。 RowIndex)。细胞( 1 )。值)
你也可以使用来自BCL的String.Format
方法,而不是VB特定的格式
函数:
字符串 .Format( {0 :00000-00000-00000-00000},ItemsDataGridView.Rows(e.RowIndex).Cells( 1 )。Value)
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
Format("00000-00000-00000-00000")
.
This is my code:
ItemsDataGridView.Rows(e.RowIndex).Cells(1).FormattedValue.ToString
I'm getting a value from datagridview, it worked but u tried using this:
Format("00000-00000-00000-00000", ItemsDataGridView.Rows(e.RowIndex).Cells(1).FormattedValue.ToString)
and this
Format("#####-#####-######-#####", ItemsDataGridView.Rows(e.RowIndex).Cells(1).FormattedValue.ToString)
none of that worked, instead of displaying
15823-58142-71635-88888, 15823581427163588888
displayed
Thanks :D
解决方案
Try taking off theToString
call, and use theValue
property instead of theFormattedValue
:
Format("00000-00000-00000-00000", ItemsDataGridView.Rows(e.RowIndex).Cells(1).Value)
You could also use theString.Format
method from the BCL, instead of the VB-specificFormat
function:
String.Format("{0:00000-00000-00000-00000}", ItemsDataGridView.Rows(e.RowIndex).Cells(1).Value)
这篇关于在VB.NET中使用格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文