2010年11月18日 星期四

婚前婚後大不同~ 好厲害的畫家

 

圖畫就是上圖轉來轉去的這一張ㄚ^^noname.gif

image

婚前婚後大不同~ 好厲害的畫家 @ Tony!(一鳴)~分享,成長,學習 ~ :: 痞客邦 PIXNET ::

等候5秒

image

Imports System
Imports System.Threading

Module Module1
    '修改此參數可改變等候時間數, 下面例子為5秒
    Dim waitN As New TimeSpan(0, 0, 5)
    Sub Main()
        Dim newThread As New Thread(AddressOf Waiting)
        newThread.Start()
        Console.WriteLine("開始...")
        If newThread.Join(TimeSpan.op_Addition(waitN, waitN)) Then
            Console.WriteLine("5秒時間到!")
        End If
        Console.ReadKey()
    End Sub

    Sub Waiting()
        Thread.Sleep(waitN)
    End Sub
End Module

修改自: http://webcache.googleusercontent.com/search?q=cache:1MwDSgUyYj8J:msdn.microsoft.com/zh-tw/library/274eh01d(VS.80).aspx+vb.new+threading+sleep&cd=1&hl=zh-TW&ct=clnk&gl=tw

Thread.Sleep 方法 (TimeSpan) (System.Threading)

 

如何搭配 Sleep 方法來使用 TimeSpan 值的作法。

Visual Basic

Imports System
Imports System.Threading

Public Class Test

Shared waitTime As New TimeSpan(0, 0, 1)

<MTAThread> _
Shared Sub Main()
Dim newThread As New Thread(AddressOf Work)
newThread.Start()

If newThread.Join( _
TimeSpan.op_Addition(waitTime, waitTime)) Then

Console.WriteLine("New thread terminated.")
Else
Console.WriteLine("Join timed out.")
End If
End Sub

Shared Sub Work()
Thread.Sleep(waitTime)
End Sub

End Class



Thread.Sleep 方法 (TimeSpan) (System.Threading)

2010年11月16日 星期二

'Dictionary Sample 2

'Dictionary Sample 2
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim str1 = ""
        Dim dict1 As New Dictionary(Of String, String)

        dict1.Add("A", "優")
        dict1.Add("B", "佳")
        dict1.Add("C", "可")
        dict1.Add("D", "差")

        str1 = str1 & vbNewLine
        'KeyValuePair
        For Each kvp As KeyValuePair(Of String, String) In dict1
            str1 = str1 & kvp.Key & Space(3) & kvp.Value & vbNewLine
        Next kvp

        'assign value
        dict1("D") = "劣"

        'ValueCollection
        Dim valueColl As Dictionary(Of String, String).ValueCollection = dict1.Values
        str1 = str1 & vbNewLine
        For Each s As String In valueColl
            str1 = str1 & "Value = " & s & vbNewLine
        Next s

        'KeyCollection
        Dim keyColl As Dictionary(Of String, String).KeyCollection = dict1.Keys

        str1 = str1 & vbNewLine
        For Each s As String In keyColl
            str1 = str1 & "Key = " & s & vbNewLine
        Next s

        'Query
        str1 = str1 & vbNewLine
        str1 = str1 & dict1("C") & vbNewLine

        'Remove
        str1 = str1 & vbNewLine & "Remove(""C"")"

        dict1.Remove("C")

        'ContainsKey
        str1 = str1 & vbNewLine
        If Not dict1.ContainsKey("C") Then
            str1 = str1 & "Key ""C"" is not found."
        End If
        MsgBox(str1)
    End Sub
End Class

VB 2008 Dictionary Sample

'Dictionary Sample
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim str1 = ""
        Dim dict1 As New Dictionary(Of Integer, String)

        dict1.Add(0, "優")
        dict1.Add(1, "佳")
        dict1.Add(2, "可")
        dict1.Add(3, "差")

        str1 = str1 & vbNewLine
        'KeyValuePair
        For Each kvp As KeyValuePair(Of Integer, String) In dict1
            str1 = str1 & kvp.Key & Space(3) & kvp.Value & vbNewLine
        Next kvp

        'assign value
        dict1(3) = "劣"

        'ValueCollection
        Dim valueColl As Dictionary(Of Integer, String).ValueCollection = dict1.Values
        str1 = str1 & vbNewLine
        For Each s As String In valueColl
            str1 = str1 & "Value = " & s & vbNewLine
        Next s

        'KeyCollection
        Dim keyColl As Dictionary(Of Integer, String).KeyCollection = dict1.Keys

        str1 = str1 & vbNewLine
        For Each s As String In keyColl
            str1 = str1 & "Key = " & s & vbNewLine
        Next s

        'Query
        str1 = str1 & vbNewLine
        str1 = str1 & dict1(2) & vbNewLine

        'Remove
        str1 = str1 & vbNewLine & "Remove(2)"

        dict1.Remove(2)

        'ContainsKey
        str1 = str1 & vbNewLine
        If Not dict1.ContainsKey(2) Then
            str1 = str1 & "Key ""2"" is not found."
        End If
        MsgBox(str1)
    End Sub
End Class

Learning

集合初始設定 (Visual Basic)

 

Dim days = New Dictionary(Of Integer, String)

days.Add(0, "Sunday")

days.Add(1, "Monday")

集合初始設定式概觀 (Visual Basic)

2010年11月11日 星期四

乙丙級術科評分系統暨Word VBA實務應用教師研習

image
乙丙級術科評分系統暨Word VBA實務應用教師研習

2010年11月5日 星期五

二進位列舉應用

'二進位列舉應用
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim str1 = ""
        Dim str2 = ""
        Dim a() = {0, 1}
        Dim e1, e2, e3, e4
        For Each e4 In a
            For Each e3 In a
                For Each e2 In a
                    For Each e1 In a
                        str1 = str1 & e4 & e3 & e2 & e1 & vbNewLine
                        str2 = str2 & IIf(e4 = 1, "(肉)", "肉") & IIf(e3 = 1, "(菜)", "菜") & IIf(e2 = 1, "(蛋)", "蛋") & IIf(e1 = 1, "(果)", "果") & vbNewLine
                    Next
                Next
            Next
        Next
        MsgBox(str1 & vbNewLine & str2)
        End
    End Sub
End Class

二進位列舉

'二進位列舉
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim str1 = ""
        Dim a() = {0, 1}
        Dim e1, e2, e3, e4
        For Each e4 In a
            For Each e3 In a
                For Each e2 In a
                    For Each e1 In a
                        str1 = str1 & e4 & e3 & e2 & e1 & vbNewLine
                    Next
                Next
            Next
        Next
        MsgBox(str1)
    End Sub
End Class