Visual Basic 2005 (VB.net 2.0) hana@arbor.ee.ntu.edu.tw 立
六 數 串 數數 數 數
串 數
串 數 Len( 串 ) 串 度 Len( 123 )=3 LCase( 串 ) 串 LCase( AnB123 ) anb123 UCase( 串 ) 串 UCase( AnB123 ) ANB123
串 數 InStr([ ], 串 1, 串 2[, ]) 串 2 串 1 不 0 InStr( abcdecd, cd ) 3 InStr(4, abcdecd, cd ) 6
串 數 InStr([ ], 串 1, 串 2[, ]) : CompareMethod.Binary CompareMethod.Text 不 InStr(1, abcd, Cd,vbBinaryCompare) 0 InStr(1, abcd, Cd,vbTextCompare) 3
串 數 Microsoft.VisualBasic.Strings.Left( 串, 度 ) 串 Microsoft.VisualBasic.Strings.Left( test1 test2,5) test1 Microsoft.VisualBasic.Strings.Right( 串, 度 ) 串 Microsoft.VisualBasic.Strings.Right( test1 test2,5) test2 Mid( 串, [, 度 ]) 串 : Mid( test test,6) test Mid( test test,6,3) tes
串 數 (cont d) LTrim( 串 ) : Trim( test ) test RTrim( 串 ) : Trim( test ) test Trim( 串 ) : Trim( test ) test
練 1: email
練 2:
數 數
數 數 Abs Sgn Ceiling Floor Round Fix Int CInt Max Min Exp Pow Sqrt Log Log10 Sin Cos Tan Atan Randomize Rnd 數 數 Math. Math.Abs(-7.6)
數 數 Abs(x) x Math.Abs(69.6) 69.6 Math.Abs(-69.6) 69.6 Sgn(x) x 若 x>0 1 Math.Sgn(9.5) 1 若 x=0 0 Math.Sgn(0) 0 若 x<0-1 Math.Sgn(-7) -1
數 數 數 Ceiling(x) 不 x 數 Math.Ceiling(12.45) 13 Math.Ceiling(-2.3) -2 Floor(x) 不 x 數 Math.Floor (12.45) 12 Math.Floor (-2.3) -3
數 數 數 Round(x) x 數 Math.Round(12.4) 12 Math.Round(-3.5) -4 Fix(x) x 數 數 Fix 不 Math. Fix(9.6) 9 Fix(-9.6) -9
數 數 數 Int(x) 不 x 數 Int 不 Math. Int(9.6) 9 Int(-9.6) -10
數 數 數 CInt( 參數 ) 來 ( 串 ) 數 : *.5 不 CInt(0.4) 0 CInt(0.6) 1 CInt(0.5) 0 CInt(1.5) 2 數
數 數 Max(x y) Math.Max(12 23) 23 Min(x y) Math.Min(12 23) 12
數 數 數 數 Exp(x) e x Math.Exp(1)= 2.71828182845905 Pow(x y) x y Math.Pow(2 3) 8
數 數 Sqrt(x) x Math.Sqrt(16) 4
數 數 數 數 Log(x) 數 Math.Log(10) 2.30258509299405 Log10(x) 10 數 Math.Log10(10) 1
數 數 數 Sin (x) 數 x 度 Math.Sin(30 * Math.PI / 180) Cos(x) x 度 Math.Cos(60 * Math.PI / 180) Tan(x) <-> Atan(x) 切 數 x 度 Math.Tan(45 * Math.PI / 180)
數 IsNumeric(expression) 數 數 True 數 False
數 數 亂數 Randomize(x) 亂數 Rnd([x]) Single 亂數 亂數 1 零
數 數 亂數 亂數 1 100 數 Int(((100-1)+1)*Rnd()+1) Int((( - )+1)*Rnd()+ )
InputBox(,[ ],[ ] ) 串 = InputBox( ) Dim InRes As String InRes = InputBox(,, )
練 : 數
MsgBox(,[ ],[ ]) MsgBox( Nice to meet you! )
- 類 MsgBoxStyle.OKOnly MsgBoxStyle.OKCancel MsgBoxStyle.AbortRetryIgnore MsgBoxStyle.YesNoCancel MsgBoxStyle.YesNo MsgBoxStyle.RetryCancel 0 1 2 3 4 5 略
- MsgBoxStyle.DefaultButton1 MsgBoxStyle.DefaultButton2 MsgBoxStyle.DefaultButton3 MsgBoxStyle.DefaultButton4 0 256 512 768
- MsgBoxStyle.Critical MsgBoxStyle.Question MsgBoxStyle.Exclamation MsgBoxStyle.Information 16 32 48 64
類 + + MsgBox( Do you like me?, 4+64+0) MsgBox( Nice to meet you! ) Dim ans as integer ans = MsgBox( Do you like me?, 4+64+0)
MsgBoxResult.OK MsgBoxResult.Cancel MsgBoxResult.Abort MsgBoxResult.Retry MsgBoxResult.Ignore MsgBoxResult.Yes MsgBoxResult.No 1 2 3 4 5 6 7
練 : 數 +?
數
數 Day Month Year Today MonthName Hour Minute Second Now WeekDayName
數 Today: Today 2000/10/20 Now: Now 2000/10/20 12:59:30
數 (cont d) 年 Year(Date 數 ) Month(Date 數 ) Day(Date 數 )
數 (cont d) Hour(Date 數 ) Minute(Date 數 ) Second(Date 數 )
數 (cont d) Weekday( 數 [, ]) Weekday(Today()) 6 FirstDayOfWeek.Sunday FirstDayOfWeek.Monday FirstDayOfWeek.Tuesday FirstDayOfWeek.Wednesday FirstDayOfWeek.Thursday FirstDayOfWeek.Friday FirstDayOfWeek.Saturday
數 IsDate(Expression)
(Timer) 拉 Interval Interval 0 不 Timer Tick 理 行
Private Sub Form1_Load Timer1.Interval = 1000 Timer1.Enabled = True End Sub Private Sub Timer1_Tick Static count As Integer count = count + 1 Label1.Text = count End Sub
練 : 數 +
~