公告版位

沒有痛苦 就沒有收穫
若內容對你有幫助,可以留言讓我知道哦~
有問題想要諮詢可以請至這裡連絡我哦 =>不會就放這邊

 


目前分類:VB (120)

瀏覽方式: 標題列表 簡短摘要

以程式設計方式放置控制項

Button1.Location = New Point(100, 100)

 

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

範例

Dim PictureBox1 As New PictureBox()
Dim WithEvents Button1 As New Button

<STAThread()> _
Public Shared Sub Main()
    Application.EnableVisualStyles()
    Application.Run(New Form1())
End Sub

Private Sub InitializePictureBoxAndButton()

    Me.Controls.Add(PictureBox1)
    Me.Controls.Add(Button1)
    Button1.Location = New Point(175, 20)
    Button1.Text = "Stretch"

    ' Set the size of the PictureBox control.
    Me.PictureBox1.Size = New System.Drawing.Size(140, 140)

    'Set the SizeMode to center the image.
    Me.PictureBox1.SizeMode = PictureBoxSizeMode.CenterImage

    ' Set the border style to a three-dimensional border.
    Me.PictureBox1.BorderStyle = BorderStyle.Fixed3D

    ' Set the image property.
    Me.PictureBox1.Image = New Bitmap(GetType(Button), "Button.bmp")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    ' Set the SizeMode property to the StretchImage value.  This
    ' will enlarge the image as needed to fit into
    ' the PictureBox.
    PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

VB語法  Try...Catch...Finally 範例

Try
    Process.Start("http://www.microsoft.com")
Catch ex As Exception
    MsgBox("Can't load Web page" & vbCrLf & ex.Message)
End Try

 

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

VB  Select...Case語法範例   https://docs.microsoft.com/zh-tw/dotnet/visual-basic/language-reference/statements/select-case-statement

Dim number As Integer = 8
Select Case number
    Case 1 To 5
        Debug.WriteLine("Between 1 and 5, inclusive")
        ' The following is the only Case clause that evaluates to True.
    Case 6, 7, 8
        Debug.WriteLine("Between 6 and 8, inclusive")
    Case 9 To 10
        Debug.WriteLine("Equal to 9 or 10")
    Case Else
        Debug.WriteLine("Not between 1 and 10, inclusive")
End Select

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

今天在搜尋visual studio序號價錢時 ,看到這篇文章介紹,目前,有個團隊研發「SharpDevelop」的開源程式,介面大概跟Visual Studio 有著87%像阿!!

目前已經用這麼做了一專案,目前上沒有任何相容性的問題,額外的參考檔也是妥妥的可以加入,如果要省去序號價錢的朋友可以考慮這款...

官方網站  http://www.icsharpcode.net/OpenSource/SD/Default.aspx  真心覺得開發出這個軟體的人真的超屌,還開源程式碼給你

文章標籤

JL8051 發表在 痞客邦 留言(1) 人氣()

VB十六進制轉ASCII方法

    Public Function AsciiStringToHexString(ByVal asciiString As String) As String
        Dim ascii() As Byte = System.Text.Encoding.Default.GetBytes(asciiString)
        Dim count As Integer = ascii.Length
        Dim hexArray(count - 1) As String
        For idx As Integer = 0 To count - 1
            hexArray(idx) = ascii(idx).ToString("x2")
        Next
        Return String.Join(" ", hexArray)
    End Function


    Public Function HexStringToAsciiString(ByVal hexString As String) As String
        Dim array() As String = hexString.Split(New Char() {" "c}, StringSplitOptions.RemoveEmptyEntries)
        For idx As Integer = 0 To array.Length - 1
            array(idx) = Chr(CInt(String.Format("&h{0}", array(idx))))
        Next
        Return String.Join(String.Empty, array)
    End Function


    Private Sub tbxASCII_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbxASCII.TextChanged
        If Me.ActiveControl Is sender Then
            tbxHex.Text = AsciiStringToHexString(tbxASCII.Text)
        End If
    End Sub

    Private Sub tbxHex_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbxHex.TextChanged
        If Me.ActiveControl Is sender Then
            tbxASCII.Text = HexStringToAsciiString(tbxHex.Text)
        End If
    End Sub
End Class

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

寫這麼久VB,竟然不知道工具項中的名稱就叫做控制項 ,真的很蝦,今天就來弄清楚,

在VB中,可以拉取的UI介面就叫做"控制項"


文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

VB - 找出所有panel內的lable名稱

如果有panel9控制項,我要取得之中所有label控制項的name,那我該怎麼做?

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

VB -Textbox換行和不換行的方法

控制項右上角有個箭頭指過去

會出現multline的框框打勾後,就可以換行了

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

如標題 如何把中日英文變成URL編碼

在IE上 如果輸入中文 或許還可以搜尋 ,但遇上日文字就問號亂碼給你看,但其他瀏覽器事不會發生

因此要避免這問題,先把中日英文字轉成"URL"編碼,就不會這問題囉

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

專案環境VS2017

1.開頭加入

Imports System.Web

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

情境:假設 我有一個combox1 和一個 Textbox1 , 我選擇Combox1上面選項時要同時更動textbox1上的數值

方法如下:

要做這個功能要用 底下的SelectedIndex 在textbox1上面顯示

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

My.Computer.FileSystem 物件的 DeleteFile 方法可讓您刪除檔案。 提供的選項包括︰是否要將已刪除的檔案傳送至 [資源回收筒]、是否要求使用者確認應該刪除檔案,以及使用者取消該作業時該怎麼辦。 刪除文字檔 使用 DeleteFile 方法來刪除檔案。 下列程式碼示範如何刪除名為 test.txt 的檔案。
My.Computer.FileSystem.DeleteFile("C:\test.txt")
刪除文字檔並要求使用者確認應該刪除檔案 使用 DeleteFile 方法來刪除檔案,並將 showUI 設定為 AllDialogs。 下列程式碼示範如何刪除名為 test.txt 的檔案,並讓使用者確認應該刪除檔案。
              My.Computer.FileSystem.DeleteFile("C:\test.txt",
        Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
        Microsoft.VisualBasic.FileIO.RecycleOption.DeletePermanently,
        Microsoft.VisualBasic.FileIO.UICancelOption.DoNothing)
刪除文字檔並將它傳送至資源回收筒 使用 DeleteFile 方法來刪除檔案,並指定 recycle 參數的 SendToRecycleBin。 下列程式碼示範如何刪除名為 test.txt 的檔案,並將它傳送至 [資源回收筒]。
My.Computer.FileSystem.DeleteFile("C:\test.txt",
Microsoft.VisualBasic.FileIO.UIOption.AllDialogs,
Microsoft.VisualBasic.FileIO.RecycleOption.SendToRecycleBin)
文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

VB - 如何判斷輸入是否為數字
if NOT IsNumeric(TextBox1.Text) Then
   MessageBox.Show ("欄位輸入必須為數值")
   Exit Sub
End If

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

 Public Function AsciiStringToHexString(ByVal asciiString As String) As String
        Dim ascii() As Byte = System.Text.Encoding.Default.GetBytes(asciiString)
        Dim count As Integer = ascii.Length
        Dim hexArray(count - 1) As String
        For idx As Integer = 0 To count - 1
            hexArray(idx) = ascii(idx).ToString("x2")
        Next
        Return String.Join(" ", hexArray)
    End Function


    Public Function HexStringToAsciiString(ByVal hexString As String) As String
        Dim array() As String = hexString.Split(New Char() {" "c}, StringSplitOptions.RemoveEmptyEntries)
        For idx As Integer = 0 To array.Length - 1
            array(idx) = Chr(CInt(String.Format("&h{0}", array(idx))))
        Next
        Return String.Join(String.Empty, array)
    End Function


    Private Sub tbxASCII_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbxASCII.TextChanged
        If Me.ActiveControl Is sender Then
            tbxHex.Text = AsciiStringToHexString(tbxASCII.Text)
        End If
    End Sub

    Private Sub tbxHex_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbxHex.TextChanged
        If Me.ActiveControl Is sender Then
            tbxASCII.Text = HexStringToAsciiString(tbxHex.Text)
        End If
    End Sub

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

在 DataGridView 中修改

'設定自動設定欄位高度
AutoSizeRowsMode = DisplayCells

JL8051 發表在 痞客邦 留言(0) 人氣()

他的語法格式是:

Filesystem.rename(a,b)
a代表輸入的檔案,也就是要被改名的檔案

JL8051 發表在 痞客邦 留言(0) 人氣()

如何尋找同一資料夾副檔名相同的檔案?

 

Dim FileName As String
Dim result(100) As String
Dim count As Integer

    FileName = Dir("C:\temp\*.txt", vbNormal)
    count = 0
    Do While FileName <> ""
     Debug.Print FileName
     result(count) = FileName
     FileName = Dir
     count = count + 1
    Loop

JL8051 發表在 痞客邦 留言(0) 人氣()

Dim sample_voltage(5800) As Integer

Array.Clear(sample_voltage, 0, sample_voltage.Length) ' 清除矩陣


文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()

這函數超好用啊!測試code用的到

Dim RR(5) As Byte
Dim rnd As New Random()
rnd.NextBytes(RR)
Textbox1.text=RR(0)
Textbox1.text=RR(1)

 

文章標籤

JL8051 發表在 痞客邦 留言(0) 人氣()