Visual Basic

Picture Upload and save on Database

============================================================================

Imports System.Data.OleDb
Imports System.IO

Public Class Form1

Dim imgName As String
Dim daImage As OleDbDataAdapter
Dim dsImage As DataSet

Private Sub Table1BindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles Table1BindingNavigatorSaveItem.Click
Me.Validate()
Me.Table1BindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.PicSaveDataSet)

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
‘TODO: This line of code loads data into the ‘PicSaveDataSet.Table1’ table. You can move, or remove it, as needed.
Me.Table1TableAdapter.Fill(Me.PicSaveDataSet.Table1)

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim dlgImage As FileDialog = New OpenFileDialog()

dlgImage.Filter = “Image File (*.jpg;*.bmp;*.gif)|*.jpg;*.bmp;*.gif”

If dlgImage.ShowDialog() = DialogResult.OK Then
imgName = dlgImage.FileName

Dim newimg As New Bitmap(imgName)

PicPictureBox.SizeMode = PictureBoxSizeMode.StretchImage
PicPictureBox.Image = DirectCast(newimg, Image)
End If

dlgImage = Nothing
Catch ae As System.ArgumentException
imgName = ” ”

MessageBox.Show(ae.Message.ToString())
Catch ex As Exception
MessageBox.Show(ex.Message.ToString())
End Try
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Table1BindingSource.AddNew()

End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Me.Validate()
Me.Table1BindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.PicSaveDataSet)
End Sub
End Class

==============================================

Age Calcutator Code

====================================================================================================================================
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Dim a As String
Dim b As String
Dim c As String
a = TextBox3.Text
b = TextBox1.Text
c = TextBox2.Text
Dim DOB As New DateTime(a, b, c)
Dim Years As Integer = DateDiff(DateInterval.Year, DOB, Now) – 1
Dim Months As Integer = DateDiff(DateInterval.Month, DOB, Now) Mod 12
Dim days As Integer = DateDiff(DateInterval.Day, DOB, Now) Mod 30 – 10
TextBox4.Text = Years & ” Years, ” & Months & ” Months ”
End Sub
================================================================================

Final Age Calculator
================================================================================
Public Class Form1
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim Date1 As Date
Dim Date2 As Date
Dim Date3 As Date
Dim Date4 As Date

Dim difference As TimeSpan
Date1 = Convert.ToDateTime(DateTimePicker1.Value)
Date2 = Convert.ToDateTime(DateTimePicker2.Value)
Date3 = DateTimePicker1.Value
Date4 = DateTimePicker2.Value
difference = Date2.Subtract(Date1)
TextBox5.Text = DateDiff(DateInterval.Day, Date3, Date4) Mod 30 & ” Days”
TextBox6.Text = DateDiff(DateInterval.Month, Date3, Date4) Mod 12 & ” Month”
TextBox7.Text = DateDiff(DateInterval.Year, Date3, Date4) & ” Years ”

TextBox8.Text = DateDiff(DateInterval.Year, Date3, Date4)
TextBox9.Text = DateDiff(DateInterval.Month, Date3, Date4)
TextBox10.Text = DateDiff(DateInterval.Day, Date3, Date4)
TextBox11.Text = DateDiff(DateInterval.Hour, Date3, Date4)
TextBox12.Text = DateDiff(DateInterval.Minute, Date3, Date4)
TextBox13.Text = DateDiff(DateInterval.Second, Date3, Date4)
TextBox1.Text = DateDiff(DateInterval.WeekOfYear, Date3, Date4)

End Sub

End Class
================================================================================

 

 

Loging Code =====

If TextBox1.Text = “admin” And TextBox2.Text = “1234” Then
Form2.Visible = True
Else
MessageBox.Show(“Your Passwoed is incarect”)

Dim result = MessageBox.Show(” Are you sure you want to quit”, “Are you sure?”, MessageBoxButtons.YesNoCancel)
If (result = DialogResult.Yes) Then
Application.Exit()

Advertisements