Mulai belajar VISUAL STUDIO.NET

Disini saya akan berbagi ilmu saya tentang vs.net(VisualStudio.Net) yang saya terima dipraktikum hari jumat 13.30 Wib 9/4/10 diLab.

tulisan ini membahas tentang explorasi vs.net supaya kita lebih mengenal fitur-fiturnya dan mengetahui kemudahannya..

disini kita akan membuat dua buah form. form yang pertama memuat halaman depan yang diberi nama hello dan form kedua diberi nama message. ikuti langkah-langkahnya serta lihat gambar-gambarnya:

komponen gambar diatas:
Form1, MainMenu1, ToolTip1, ColorDialog1, Label1, Button1, Button2, Button3. Propertinya disesuakan sendiri.

dan bila dijalankan seperti ini gambarnya:

setelah itu buat form yang kedua.

komponen form diatas:
form2, MainMenu1, GroupBox1, Label1, Label2, TextBox1, RichTextbox1,GroupBox2,RadioButton1,RadioButton2,RadioButton3,
PictureBox1,Label3,Label4,CheckButton1,Button1,Button2

sebelum masuk ke script form1 dan form2 kita harus buat dulu modul
dengan cara. arahkan kursor keatas projek kuliah2 trus klik kanan–>add–>add Module. dan isi dengan syntax seperti dibawah ini.

Module _Module
    Public AppPath As String = Replace(Replace(Replace(Application.ExecutablePath, Application.ProductName + ".EXE", ""), Application.ProductName + ".exe", ""), Application.ProductName + ".exe", "")
End Module

dan untuk form1nya seperti dibawah ini.

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Try
            If ColorDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
                Me.BackColor = ColorDialog1.Color
                Dim sw As New System.IO.StreamWriter(AppPath & ("Setting2.txt"))
                Dim a As String = Hex(ColorDialog1.Color.ToArgb)
                a = a.Substring(2)
                sw.WriteLine("#" & a)
                sw.Close() 'Menutup file
                System.IO.File.Delete(AppPath & ("Setting.txt"))
                System.IO.File.Move(AppPath & ("Setting2.txt"), AppPath & ("Setting.txt"))

            End If
        Catch ex As Exception

        End Try
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Application.Exit()

    End Sub

    Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
        Dim message As New Form2
        message.ShowDialog()

    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
        Label1.Text = "pertemuan pertama"

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            If System.IO.File.Exists(AppPath & ("Setting.txt")) = False Then
                Dim sw As New System.IO.StreamWriter(AppPath & ("Setting.txt"))
                Dim c As System.Drawing.Color = System.Drawing.ColorTranslator.FromHtml("Control")
                sw.WriteLine("#" & Hex(c.ToArgb))
                sw.Close()
            Else
                Dim color As String
                Dim sr As New System.IO.StreamReader(AppPath & ("Setting.txt"))
                color = sr.ReadLine()
                sr.Close()
                Dim color2 As System.Drawing.Color = System.Drawing.ColorTranslator.FromHtml(color)
                Me.BackColor = color2
            End If
        Catch ex As Exception
            MsgBox(ex.Message)

        End Try
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Dim sw As New System.IO.StreamWriter(AppPath & ("Setting2.txt"))
            Dim color2 As System.Drawing.Color = System.Drawing.ColorTranslator.FromHtml("Control")

            Me.BackColor = color2
            sw.WriteLine("#" & Hex(color2.ToArgb))
            sw.Close()
            System.IO.File.Delete(AppPath & ("Setting.txt"))
            System.IO.File.Move(AppPath & ("Setting2.txt"), AppPath & ("Setting.txt"))

        Catch ex As Exception
            MsgBox(ex.Message)

        End Try
    End Sub
End Class

serta form2nya seperti dibawah ini

Public Class Form2
    Inherits System.Windows.Forms.Form

    Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
        Form2.ActiveForm.Visible = False

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label4.Text = "dari : " & TextBox1.Text & " ,pesannya : " & RichTextBox1.Text

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Label4.Text = " "
        TextBox1.Text = " "
        RichTextBox1.Text = " "

    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If CheckBox1.Checked = False Then
            Label4.Visible = True
        Else
            Label4.Visible = False

        End If
    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        If PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage Then
            PictureBox1.SizeMode = PictureBoxSizeMode.Normal
        ElseIf PictureBox1.SizeMode = PictureBoxSizeMode.Normal Then
            PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
        End If
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        Label4.ForeColor = Color.Red

    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        Label4.ForeColor = Color.Green

    End Sub

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        Label4.ForeColor = Color.Black
    End Sub
End Class

tampilan jadinya seperti ini:

untuk sourcecode program dan gambarnya dapat didownload disini
semoga bermanfaat😉

ym: bahrie127

1 Komentar (+add yours?)

  1. maseadi
    Feb 19, 2013 @ 19:58:04

    Thank infonya…

    Balas

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: