Skip to content

Instantly share code, notes, and snippets.

@shahrulnizam
shahrulnizam / VB Timer
Created May 12, 2013 03:57
VB Lesson: Timer
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = 0
Button1.Text = "START"
Button2.Text = "RESET"
Timer1.Enabled = False
Timer1.Interval = 100
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text = Label1.Text + 1
@shahrulnizam
shahrulnizam / VB ProgressBar
Created May 12, 2013 04:00
VB Lesson: ProgressBar
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Interval = 100
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ProgressBar1.Value = 0
Timer1.Start()
Button1.Enabled = False
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
@shahrulnizam
shahrulnizam / VB ListBox
Created May 12, 2013 04:02
VB Lesson: ListBox
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Add(TextBox1.Text)
TextBox1.Text = ""
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ListBox1.Items.Remove(ListBox1.SelectedItem)
End Sub
@shahrulnizam
shahrulnizam / VB Text File Application
Created May 12, 2013 04:06
VB Lesson: Text File Application
Public Class Form1
Dim TR As System.IO.TextReader
Dim TW As System.IO.TextWriter
Dim FileName As String = "C:\MyTextFile.txt"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TW = System.IO.File.CreateText(FileName)
TW.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TW = System.IO.File.AppendText(FileName)
@shahrulnizam
shahrulnizam / VB Excel Application
Created May 12, 2013 04:09
VB Lesson: Excel Application
Imports Excel = Microsoft.Office.Interop.Excel
Public Class Form1
Dim ExcelApp As Excel.Application
Dim ExcelBook As Excel.Workbook
Dim ExcelSheet As Excel.Worksheet
Dim ExcelRange As Excel.Range
Dim MisValue As Object = System.Reflection.Missing.Value
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ExcelApp = New Excel.Application
@shahrulnizam
shahrulnizam / VB Login Page
Created May 12, 2013 04:34
VB Lesson: Login Page
Public Class Form1
Dim TR As System.IO.TextReader
Dim TW As System.IO.TextWriter
Dim FileName As String = "C:\password.txt"
Dim temp As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If System.IO.File.Exists(FileName) = False Then
TW = System.IO.File.CreateText(FileName)
TW.Write("admin" & " " & "123456")
TW.Close()
@shahrulnizam
shahrulnizam / VB Plot Graph
Created May 12, 2013 04:36
VB Lesson: Plot Graph
Public Class Form1
Dim x As Integer = 0
Dim array(100) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Text = "Start"
NumericUpDown1.Minimum = 1
NumericUpDown1.Maximum = 100
Chart1.Series.Clear()
Chart1.Series.Add("A")
Chart1.ChartAreas("ChartArea1").AxisX.Minimum = 0
@shahrulnizam
shahrulnizam / VB Serial Port
Created May 12, 2013 04:37
VB Lesson: Serial Port
Public Class Form1
Dim Rx(20) As Byte
Dim ADC As Integer
Dim i As Integer
Dim j As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SerialPort1.PortName = "COM4"
SerialPort1.BaudRate = 9600
SerialPort1.Parity = IO.Ports.Parity.None
SerialPort1.StopBits = IO.Ports.StopBits.One
@shahrulnizam
shahrulnizam / VB Servo Motor
Created May 14, 2013 02:07
chipKIT Lesson: Servo Motor
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Text = "Connect"
HScrollBar1.Enabled = False
HScrollBar1.Minimum = 0
HScrollBar1.Maximum = 189
Timer1.Interval = 100
End Sub
@shahrulnizam
shahrulnizam / Arduino Sensor DHT22
Last active March 7, 2019 10:37
Arduino Lesson: Sensor DHT22
/*
Project: Sensor DHT22 Lesson
Programmer: Shahrulnizam Mat Rejab
Board: Arduino Uno
Last Modified: 7 March 2019
Website: http://shahrulnizam.com
*/
#define INTERVAL 500