Monday, June 3, 2013

Create Void Recorder with vb.net



Public Class Form1
    Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstyCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Interval = 1000
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Label3.Text = "0.0"
        Button1.Enabled = False
        Button2.Enabled = True
        mciSendString("open new Type waveaudio Alias recsound", "", 0, 0)
        mciSendString("record recsound", "", 0, 0)
        Timer1.Enabled = True
        Label1.Text = "កំពុងថតសម្លេង...!"
        Label1.Visible = True
        Label2.Text = "File Location: "
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Button1.Enabled = True
        Button2.Enabled = False

        Label1.Text = "ការថតថម្លេងបានបញ្ចប់"
        SaveFileDialog1.Title = "Save File Audio"
        SaveFileDialog1.FileName = ""
        SaveFileDialog1.Filter = "File MP3|*.mp3|File Wave|*.wav"
        SaveFileDialog1.FilterIndex = 2
        SaveFileDialog1.OverwritePrompt = True
        SaveFileDialog1.ShowDialog()

        mciSendString("save recsound " & SaveFileDialog1.FileName & "", "", 0, 0)
        mciSendString("close recsound", "", 0, 0)
        Timer1.Enabled = False
        MsgBox("File Created: " & SaveFileDialog1.FileName & "", MsgBoxStyle.OkOnly, "Success")
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label3.Text += 0.01
    End Sub

    Private Sub AxWindowsMediaPlayer1_ClickEvent(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_ClickEvent) Handles AxWindowsMediaPlayer1.ClickEvent
        AxWindowsMediaPlayer1.URL = SaveFileDialog1.FileName
        AxWindowsMediaPlayer1.Ctlcontrols.play()
        Label2.Text += SaveFileDialog1.FileName
        Label1.Text = "កំពុងតែចាក់ស្តាប់"
    End Sub
End Class

Sunday, June 2, 2013

Create you own shutdown management control system


Public Class Form2
    Dim i, j As Integer
    Dim TM As Date
    Private Declare Function LockWorkStation Lib "user32.dll" () As Long
    Private Declare Function ShutDownDialog Lib "shell32.all" Alias "#60" (ByVal any As Long)

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Me.Text = "Shutdown Manager - " + TimeOfDay
        Me.Label3.Text = "ពេលវេលាបច្ចុប្បន្ន៖ " + TimeOfDay
    End Sub

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer2.Interval = 10000
        Timer1.Enabled = True

        For Me.i = 0 To 23 Step 1
            cboHourse.Items.Add(i)
        Next

        For Me.j = 0 To 60 Step 1
            cboMinutes.Items.Add(j)
        Next
    End Sub

    Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click
        cmdStart.Text = "កំពុងដំណើរការ"
        If Val(cboHourse.Text) > 0 Or Val(cboMinutes.Text) > 0 Then
            TM = Now.AddMinutes(Val(cboHourse.Text) * 60 + Val(cboMinutes.Text))
            Timer2.Enabled = True
            lblStatuse.Text = "កំណត់ពេលវេលាគឺ៖ " + TM

        Else
            lblStatuse.Text = "សូមបញ្ចូលពេលវេលាជាមុន"
        End If
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        If Now > TM Then
            If RdoLogOff.Checked = True Then
                Shell("shutdown -l")
            End If

            If RdoRestart.Checked = True Then
                Shell("shutdown -r")
            End If

            If RdoShutDown.Checked = True Then
                Shell("shutdown -s")
            End If

            If RdoLockPC.Checked = True Then
                LockWorkStation()
            End If

            If RdoHybernate.Checked = True Then
                Shell("shutdown -h")
            End If

            Timer1.Enabled = False
            Timer2.Enabled = False
        End If
    End Sub

    Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
        cmdStart.Text = "Start"
        Timer2.Enabled = False
        lblStatuse.Text = "ប្រព័ន្ធអាចចាប់ផ្តើមជាថ្មីបាន!"
    End Sub

    Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
        End
    End Sub
End Class

Saturday, June 1, 2013

Create Stop Watch with Vb.net

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Button1.Text = "ចាប់ផ្តើម" Then
            Timer1.Enabled = True
            Button1.Text = "ផ្អាក"
            Button3.Enabled = False
        Else
            Button1.Text = "ផ្អាក"
            Timer1.Enabled = False
            Button1.Text = "ចាប់ផ្តើម"
            Button3.Enabled = True
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Interval = 1
        Button1.Text = "ចាប់ផ្តើម"
        Button3.Text = "សារដើម"
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Timer1.Enabled = False
        Label1.Text = "0.0"
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = Label1.Text + 0.01
    End Sub
End Class


Friday, May 31, 2013

Create a Date and Time using Cambodia Time


Imports System.Globalization
Public Class Form1
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = DateTime.Now.ToString("dddd 'ទី'dd 'ខែ'MMMM 'និងម៉ោង'​h:mm:ss tt 'ត្រូវនឹងពេលវេលានៅភ្នំពេញណាបាទ!'", CultureInfo.CreateSpecificCulture("km-KH"))
        Me.Label2.Text = TimeOfDay
    End Sub
End Class

Created by RUPP LKT :D 

VB.net with Listview Alarm Clock




Public Class Form1

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Me.Label1.Text = TimeOfDay

        For Each item As ListViewItem In Me.ListView1.Items
            If item.SubItems(0).Text = Me.Label1.Text Then
                MsgBox(item.SubItems(1).Text)
            End If
        Next
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        'Allow the user to remove the alarm
        If Me.ListView1.SelectedItems.Count > Nothing Then
            Me.ListView1.SelectedItems(0).Remove()
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim myAlarmTime As String
        Dim myAlarmName As String
        myAlarmTime = InputBox("Please add the time of the alarm")
        myAlarmName = InputBox("Please select a name")

        Dim lvitem As ListViewItem
        lvitem = Me.ListView1.Items.Add(myAlarmTime)
        lvitem.SubItems.Add(myAlarmName)

    End Sub
End Class

This code was copy right by RUPP Student