Total Pageviews

Sunday, October 23, 2016

Resize Images In VB.NET

This code can be used to resize images in Visual Basic 2015 too.

Try
    SaveFileDialog1.Filter = "JPEG|*.jpg"
    If SaveFileDialog1.ShowDialog = DialogResult.OK Then
        Using bm As New Bitmap(PictureBox1.Image, 1024, 500)
            bm.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
            bm.Save(PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage)
        End Using
        MsgBox("Your File Created")
     End If
 Catch ex As Exception
End Try


1024, 500 cab be intered trough textboxes too

Try
    SaveFileDialog1.Filter = "JPEG|*.jpg"
    If SaveFileDialog1.ShowDialog = DialogResult.OK Then
        Using bm As New Bitmap(PictureBox1.Image, txtbox1.Text,
txtbox2.Text,)
            bm.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
            bm.Save(PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage)
        End Using
        MsgBox("Your File Created")
     End If
 Catch ex As Exception
End Try

Friday, October 14, 2016

Restrict TextBox only to Numeric Input

Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles TextBox1.KeyPress
    Select Case e.KeyChar
    Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", vbBack
        e.Handled = False
    Case Else
        e.Handled = True
    End Select
End Sub