vbscript [.net] VB.NET笔记

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript [.net] VB.NET笔记相关的知识,希望对你有一定的参考价值。

'-----------------------------------
'MULTI-DIMENSIONAL ARRAY
'-----------------------------------

'*** Create Array and append values to it
Dim itemsArray As String()() = New String(0)() {}
For i = 1 To 3
  ReDim Preserve itemsArray(i)
  itemsArray(i) = New String() {"1", "2", "3"}
Next

'Output:
'  1 2 3
'  1 2 3
'  1 2 3

'*** Free array's memory
Array.Clear(itemsArray, 0, itemsArray.Length)
Erase itemsArray


'-----------------------------------
'NUMBER FORMATTING
'-----------------------------------

Dim FormattedNumber As String = String.Format("{0:N0}", 123456)
'Output: 123,456

'*** Decimals:
'use 'F' fixed point format with '3' decimal places.
Dim PrintableNumber As String = String.Format("{0:F3}", 0.126467382626182)
'Output: 0.126

'*** Padding:
'The 'D' means padded decimal integer and the '4' means to 4 places, 
'so you end up with a 4 digit printable number that's prefixed with 0's where needed.
Dim Result As Integer = 20
Dim PrintableNumber As String = String.Format("{0:D4}", Result)
'Output: 0020


'-----------------------------------
'DATE & TIME FORMATTING
'-----------------------------------

Dim MyDate As String = String.Format("{0}", DateTime.Now)
'Output: 14/04/2014 13:47:32
'Which will be formatted according to your local culture settings.

'Just as with the number formatting strings, there is a wide range of possible operators 
'you can use here to get just the format you need; for example:
Dim MyDate As String = String.Format("{0:r}", DateTime.Now)
'Output: Mon, 14 Apr 2014 13:52:41 GMT

'Where as:
Dim MyDate As String = String.Format("{0:s}", DateTime.Now)
'Output: 2014-04-14T13:53:37

'Custom formatting:
Dim MyDate As String = String.Format("{0:yyyy - dd MMMM @ hh:mm tt}", DateTime.Now)
'Output: 2014 - 14 April @ 01:57 PM



以上是关于vbscript [.net] VB.NET笔记的主要内容,如果未能解决你的问题,请参考以下文章

vbscript [VB.NET]新事物#test

vbscript Varios Razor VB.NET

vbscript VB.net正常运行时间报告

vbscript VB.net中提示模块的模板

vbscript 从vb.net后面的代码调用javascript函数

vbscript 这向您展示了在Dynamo VB.Net中拆分字符串的最佳方法