• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

VB.NET Int64.Parse方法代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了VB.NET中System.Int64.Parse方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Int64.Parse方法的具体用法?VB.NET Int64.Parse怎么用?VB.NET Int64.Parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Int64的用法示例。



在下文中一共展示了Int64.Parse方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。

示例1: ParseInt64

' 导入命名空间
Imports System.Globalization

Module ParseInt64
   Public Sub Main()
      Convert("12,000", NumberStyles.Float Or NumberStyles.AllowThousands, _
              New CultureInfo("en-GB"))      
      Convert("12,000", NumberStyles.Float Or NumberStyles.AllowThousands, _
              New CultureInfo("fr-FR"))
      Convert("12,000", NumberStyles.Float, New CultureInfo("en-US"))
      
      Convert("12 425,00", NumberStyles.Float Or NumberStyles.AllowThousands, _
              New CultureInfo("sv-SE")) 
      Convert("12,425.00", NumberStyles.Float Or NumberStyles.AllowThousands, _
              NumberFormatInfo.InvariantInfo) 
      Convert("631,900", NumberStyles.Integer Or NumberStyles.AllowDecimalPoint, _ 
              New CultureInfo("fr-FR"))
      Convert("631,900", NumberStyles.Integer Or NumberStyles.AllowDecimalPoint, _
              New CultureInfo("en-US"))
      Convert("631,900", NumberStyles.Integer Or NumberStyles.AllowThousands, _
              New CultureInfo("en-US"))
   End Sub

   Private Sub Convert(value As String, style As NumberStyles, _
                       provider As IFormatProvider)
      Try
         Dim number As Long = Int64.Parse(value, style, provider)
         Console.WriteLine("Converted '{0}' to {1}.", value, number)
      Catch e As FormatException
         Console.WriteLine("Unable to convert '{0}'.", value)
      Catch e As OverflowException
         Console.WriteLine("'{0}' is out of range of the Int64 type.", value)   
      End Try
   End Sub                       
End Module
' This example displays the following output to the console:
'       Converted '12,000' to 12000.
'       Converted '12,000' to 12.
'       Unable to convert '12,000'.
'       Converted '12 425,00' to 12425.
'       Converted '12,425.00' to 12425.
'       '631,900' is out of range of the Int64 type.
'       Unable to convert '631,900'.
'       Converted '631,900' to 631900.
开发者ID:VB.NET开发者,项目名称:System,代码行数:44,代码来源:Int64.Parse


示例2: ParseInt64

' 导入命名空间
Imports System.Globalization

Module ParseInt64
   Public Sub Main()
      Convert("104.0", NumberStyles.AllowDecimalPoint)    
      Convert("104.9", NumberStyles.AllowDecimalPoint)
      Convert (" 106034", NumberStyles.None)
      Convert(" $17,198,064.42", NumberStyles.AllowCurrencySymbol Or _
                                 NumberStyles.Number)
      Convert(" $17,198,064.00", NumberStyles.AllowCurrencySymbol Or _
                                 NumberStyles.Number)
      Convert("103E06", NumberStyles.AllowExponent)  
      Convert("1200E-02", NumberStyles.AllowExponent)
      Convert("1200E-03", NumberStyles.AllowExponent)
      Convert("-1,345,791", NumberStyles.AllowThousands)
      Convert("(1,345,791)", NumberStyles.AllowThousands Or _
                             NumberStyles.AllowParentheses)
      Convert("FFCA00A0", NumberStyles.HexNumber)                       
      Convert("0xFFCA00A0", NumberStyles.HexNumber)                       
   End Sub
   
   Private Sub Convert(value As String, style As NumberStyles)
      Try
         Dim number As Long = Int64.Parse(value, style)
         Console.WriteLine("Converted '{0}' to {1}.", value, number)
      Catch e As FormatException
         Console.WriteLine("Unable to convert '{0}'.", value)
      Catch e As OverflowException
         Console.WriteLine("'{0}' is out of range of the Int64 type.", value)   
      End Try
   End Sub
End Module
开发者ID:VB.NET开发者,项目名称:System,代码行数:33,代码来源:Int64.Parse

输出:

Converted '104.0' to 104.
104.9' is out of range of the Int64 type.
Unable to convert ' 106034'.
$17,198,064.42' is out of range of the Int64 type.
Converted ' $17,198,064.00' to 17198064.
Converted '103E06' to 103000000.
Converted '1200E-02' to 12.
1200E-03' is out of range of the Int64 type.
Unable to convert '-1,345,791'.
Converted '(1,345,791)' to -1345791.
Converted 'FFCA00A0' to 4291428512.
Unable to convert '0xFFCA00A0'.


示例3: ParseInt64

Module ParseInt64
   Public Sub Main()
      Convert("  179032  ")
      Convert(" -2041326 ")
      Convert(" +8091522 ")
      Convert("   1064.0   ")
      Convert("  178.3")
      Convert(String.Empty)
      Convert((CDec(Int64.MaxValue) + 1).ToString())
   End Sub

   Private Sub Convert(value As String)
      Try
         Dim number As Long = Int64.Parse(value)
         Console.WriteLine("Converted '{0}' to {1}.", value, number)
      Catch e As FormatException
         Console.WriteLine("Unable to convert '{0}'.", value)
      Catch e As OverflowException
         Console.WriteLine("'{0}' is out of range.", value)      
      End Try
   End Sub
End Module
' This example displays the following output to the console:
'       Converted '  179032  ' to 179032.
'       Converted ' -2041326 ' to -2041326.
'       Converted ' +8091522 ' to 8091522.
'       Unable to convert '   1064.0   '.
'       Unable to convert '  178.3'.
'       Unable to convert ''.
'       '9223372036854775808' is out of range.
开发者ID:VB.NET开发者,项目名称:System,代码行数:30,代码来源:Int64.Parse


示例4: CultureInfo

Protected Sub OkToLong_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OkToLong.Click
   Dim locale As String
   Dim culture As CultureInfo
   Dim number As Long

   ' Return if string is empty
   If String.IsNullOrEmpty(Me.inputNumber.Text) Then Exit Sub

   ' Get locale of web request to determine possible format of number
   If Request.UserLanguages.Length = 0 Then Exit Sub
   locale = Request.UserLanguages(0)
   If String.IsNullOrEmpty(locale) Then Exit Sub

   ' Instantiate CultureInfo object for the user's locale
   culture = New CultureInfo(locale)

   ' Convert user input from a string to a number
   Try
      number = Int64.Parse(Me.inputNumber.Text, culture.NumberFormat)
   Catch ex As FormatException
      Exit Sub
   Catch ex As Exception
      Exit Sub
   End Try

   ' Output number to label on web form
   Me.outputNumber.Text = "Number is " & number.ToString()
End Sub
开发者ID:VB.NET开发者,项目名称:System,代码行数:28,代码来源:Int64.Parse



注:本文中的System.Int64.Parse方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
VB.NET Math.BigMul方法代码示例发布时间:2022-05-24
下一篇:
VB.NET Int32.Parse方法代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap