標籤雲

visual basic 2008 (157) 訊息分享 (111) Visual Studio 2008 (64) wpf (37) 每日一句 (35) cpp (30) python (26) Silverlight (22) C++ (18) Network Security (15) 全國技藝競竇 (14) 好文分享 (11) .Net (10) Blogger (10) 名詞解釋 (10) 研討會 (10) Excel (9) 書籍介紹 (9) 每日一小品 (9) 電腦黑白講 (8) Visual Studio 201X (7) 分享 (7) 網頁設計 (7) CSS (5) Algorithm (4) Network (3) PHP (3) Access (2) SA (2) VB.Net (2) VBA (2) WireShark (2) Word (2) php html (2) 其他好東東 (2) 分類整理 (2) Asp.Net (1) Batch (1) Blockly (1) IT News (1) OpenAI (1) SE (1) W7 (1) Writer (1) app inv2 (1) dfs (1) vex vr sample (1) 影像處理練習 (1) 新站連結 (1) 黑白講 (1)
顯示具有 Visual Studio 201X 標籤的文章。 顯示所有文章
顯示具有 Visual Studio 201X 標籤的文章。 顯示所有文章

2014年4月25日 星期五

Maze Sample




Public Class Form1
    Dim a(16, 16) As Integer
    Dim str1 = ""

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim fileContents As String
        fileContents = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\MData.txt")
        Dim lines() = Split(fileContents, vbNewLine)

        For i = 0 To 14
            Dim ba() = Split(lines(i), ",")
            For j = 0 To 14
                a(i + 1, j + 1) = ba(j)
            Next
        Next

        For i = 0 To 16
            a(0, i) = 2
            a(i, 0) = 2
            a(16, i) = 2
            a(i, 16) = 2
        Next

        showArray0()

        If visit(1, 1) Then
            showArray()
        Else
            MsgBox("NoPath")
        End If
        End
    End Sub

    Sub showArray0()
        Dim str3 = ""
        For i = 1 To 15
            For j = 1 To 15
                If Not a(i, j) = 2 Then
                    str3 = str3 & "○"
                Else
                    str3 = str3 & "●"
                End If
            Next
            str3 = str3 & vbNewLine
        Next
        MsgBox(str3)
    End Sub

    Sub showArray()
        Dim str3 = ""
        For i = 1 To 15
            For j = 1 To 15
                If a(i, j) = 1 Then
                    str3 = str3 & "○"
                Else
                    str3 = str3 & "●"
                End If
            Next
            str3 = str3 & vbNewLine
        Next
        MsgBox(str3)
    End Sub

    Function visit(ByVal i As Integer, ByVal j As Integer) As Boolean
        If a(15, 15) = 1 Then Return True
        If a(i, j) = 0 Then
            a(i, j) = 1
            ' Call showArray()
            If Not a(15, 15) = 1 And Not (visit(i + 1, j) Or visit(i, j + 1) Or visit(i - 1, j) Or visit(i, j - 1)) Then
                a(i, j) = 0
            End If
        End If
        Return a(15, 15) = 1

    End Function
End Class




2014年4月22日 星期二

Resurive Sample

'' 求1+3+5+ + 99 = ?
'Public Class Form1
'    Dim sumN = 0
'    Sub sum(sN, eN, stepN)
'        '判斷結束否
'        If sN > eN Then Return

'        '每次過程要做的事
'        sumN = sumN + sN

'        '往完成工作方向前進
'        sum(sN + stepN, eN, stepN)
'    End Sub

'    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'        Call sum(1, 100, 2)
'        MsgBox(sumN)
'    End Sub
'End Class

' 求1!+2!+3!+ + 10! = ?
'Public Class Form1
'    Dim sumN = 0
'    Sub sum(sN, eN, stepN)
'        '判斷結束否
'        If sN > eN Then Return

'        '每次過程要做的事
'        Dim tsum = 1
'        For i = 1 To sN
'            tsum = tsum * i
'        Next
'        sumN = sumN + tsum

'        '往完成工作方向前進
'        sum(sN + stepN, eN, stepN)
'    End Sub

'    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'        Call sum(1, 5, 1)
'        MsgBox(sumN)
'    End Sub
'End Class


'尋找最大值
'Public Class Form1
'    Dim maxValue = 0
'    Dim a() = {10, 200, 100, 50, 30}

'    Sub fMax(sN, eN)
'        '判斷結束否
'        If sN > eN Then Return

'        '每次過程要做的事
'        If a(sN) > maxValue Then maxValue = a(sN)

'        '往完成工作方向前進
'        fMax(sN + 1, eN)
'    End Sub

'    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'        Call fMax(0, a.Length - 1)
'        MsgBox(maxValue)
'    End Sub
'End Class

重覆排列


Public Class Form1
    Dim ans(19) As String
    Dim str1 = ""
    Dim inStr = ""
    Dim ctr = 0

    Sub enu(d, n, m)
        Dim i As Integer
        If d = n Then
            For i = 0 To n - 1
                str1 = str1 & ans(i) & " "
            Next
            str1 = str1 & vbNewLine
            ctr = ctr + 1
            Return
        End If
        For i = 1 To m
            ans(d) = Mid(inStr, i, 1)
            enu(d + 1, n, m)
        Next
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim n, m As Integer
        inStr = "ABc"
        n = 3
        m = Len(inStr)
        enu(0, n, m)
        MsgBox(str1 & vbNewLine & "共" & ctr & "個")
        End
    End Sub
End Class


2014年4月1日 星期二

Kill Process

'Kill process
Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Timer1.Interval = 5000
        Timer1.Enabled = True
    End Sub

    Sub killProcess(processName)
        Dim process1 As Process()
        process1 = Process.GetProcessesByName(processName)
        For Each proces As Process In process1
            proces.Kill()
        Next
    End Sub

    Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
        System.Diagnostics.Process.Start("iexplore")
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Call killProcess("iexplore")
        Call killProcess("mspaint")
    End Sub
End Class

2011年12月21日 星期三

合計記錄值至另一筆記錄中

Imports System.Data.OleDb

Public Class Form1
    Dim cn As OleDbConnection
    Dim cnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\dbtest.mdb;Persist Security Info=True"

    Private Sub 資料表1BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 資料表1BindingNavigatorSaveItem.Click
        Me.Validate()
        Me.資料表1BindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.DbtestDataSet)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: 這行程式碼會將資料載入 'DbtestDataSet.資料表1' 資料表。您可以視需要進行移動或移除。
        Me.資料表1TableAdapter.Fill(Me.DbtestDataSet.資料表1)
    End Sub
    Sub sqlExec(ByVal sqlStr)
        Dim cmd As OleDbCommand = New OleDbCommand(sqlStr, cn)
        cmd.ExecuteNonQuery()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        '
        Dim a() = {"明", "天", "明天"}
        Dim f2Value = "後天"
        Call sumTo(a, f2Value)
        Me.資料表1TableAdapter.Fill(Me.DbtestDataSet.資料表1)
    End Sub

    Sub sumTo(ByVal a, ByVal f2Value)
        cn = New OleDbConnection(cnStr)
        cn.Open()
        '
        Dim cmd As New OleDbCommand("SELECT * FROM 資料表1", cn)
        Dim dr As OleDbDataReader = cmd.ExecuteReader()

        Dim sum = 0
        Do While dr.Read()
            For Each elm In a
                If dr.Item("f2").ToString = elm Then
                    sum = sum + dr.Item(2)
                End If
            Next
        Loop

        Dim sqlStr As String = "update 資料表1 set f3= " & sum & " where f2 =" & "'" & f2Value & "';"
        sqlExec(sqlStr)

        cn.Close()
    End Sub
End Class

image

image

2011年12月1日 星期四

SQL指令Update Access 資料庫

Imports System.Data.OleDb

Public Class Form1
    Private Sub 資料表1BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 資料表1BindingNavigatorSaveItem.Click
        Me.Validate()
        Me.資料表1BindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.DbtestDataSet)

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: 這行程式碼會將資料載入 'DbtestDataSet.資料表1' 資料表。您可以視需要進行移動或移除。
        Me.資料表1TableAdapter.Fill(Me.DbtestDataSet.資料表1)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim cn As OleDbConnection
        Dim cnStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\dbtest.mdb;Persist Security Info=True"
        cn = New OleDbConnection(cnStr)
        cn.Open()
        Dim f2Value = "fff"
        Dim f3Value = 20
        Dim sqlStr As String = "update 資料表1 set f2= '" & f2Value & "' where f3 >" & f3Value
        Dim cmd As OleDbCommand = New OleDbCommand(sqlStr, cn)
        cmd.ExecuteNonQuery()
        cn.Close()

        Me.資料表1TableAdapter.Fill(Me.DbtestDataSet.資料表1)
    End Sub
End Class

image

2011年11月27日 星期日

Visual Studio 11 的 11 個不同!

 

Visual Studio 11 的 11 個不同!

於 星期五, 十一月 25, 2011

Visual Studio 11 顯然是為微軟的 Windows 8 所準備的大餐,鑒於 Win8 對比 Win7 的變化太大,用 Visual Studio 2010 就顯得不與時俱進起來,微軟在 9 月份 BUILD 大會上發佈 Windows 8 的開發者預覽版本時,就一併對外公開提供了 Visual Studio 11 的開發者預覽版本下載。

☆數位夢想☆: Visual Studio 11 的 11 個不同!