heyy guys !! i am back with java .. , so today i am gonna teach you how to make a your very first java GUI program after that i will write more tutorial on adding controls to the interface and giving click events .. , first of all open your favorite text editor and after that these are the codes i have written so go ahead and put them in
Home » Archives for April 2013
How To Make A GUI(Graphical User Interface) In Java
heyy guys !! i am back with java .. , so today i am gonna teach you how to make a your very first java GUI program after that i will write more tutorial on adding controls to the interface and giving click events .. , first of all open your favorite text editor and after that these are the codes i have written so go ahead and put them in
How To Add Facebook Comment Box To Your Website
facebook comment box - dark
facebook comment box - light
ok now go to this link scroll down and you will see something like this
How To Make A Simple Digital Clock Using Javascript
i remember i have written a tutorial on making a clock using javascript before but i know that it was not explained and that codes were not clean so i thought make it again with nice codes . first we need to create a html document to make a the javascript codes work or make the javascript functions work so go ahead and create a new html document and type the regular html tags and under head tag add these codes
now close the head tag and start the body tag now put these codes there
now close the body tag and check your html page boom ! a small digital clock in javascript ! you can also use some awesome css and some other things to make this beautiful !
How To Play A Wave Sound File In Background Mode In C#
this is gonna be a snippet and i call it a useful snippet , you just need to add a namespace and add 4 lines of codes to a event .
add this namespace :
Using System.Media;
after that you need to add these 4 lines of codes for a event (for example form_load , button_click)
SoundPlayer wave = new SoundPlayer(); string path = "path to .WAV"; wave.SoundLocation = path; wave.Play();
now replace path to .WAV with the destination (for example C:/new folder/hello.wav)
i hope you enjoy this !
Drop Shadow At The Form Border In C#
i hope you guys didn't forget the same thing that i have written for VB.NET . alright like that we are now going to make the form border drop shadow that will make the form look awesome :) if your on a project that doesn't matter or create a new project to test it .
under
public partial class Form1 : Form {
add these codes
protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ClassStyle |= CS_DROPSHADOW; return cp; } }
now debug and enjoy the shadow
share ! comment ! like us on facebook ! follow us on twitter !
How To Validate Textbox : Only Numbers, Only Characters, Not Null, Only Email in VB.NET
in
assign,
textbox,
tutorial,
validate email,
validation,
vb.net
- By
Mohamed Shimran
- on 4/09/2013
- 6 comments
Today I have brought you something delicious :) so you guys wonder how it works , first we have to create a module and we just have to assign the textbox for a validation (Only Number,Only Characters,Not Null,Only Email) so first of all lets create a new module and add this codes
Imports System.Text.RegularExpressions Module Module1 Public Enum ValidationType Only_Numbers = 1 Only_Characters = 2 Not_Null = 3 Only_Email = 4 End Enum Public Sub AssignValidation(ByRef CTRL As Windows.Forms.TextBox, ByVal Validation_Type As ValidationType) Dim txt As Windows.Forms.TextBox = CTRL Select Case Validation_Type Case ValidationType.Only_Numbers AddHandler txt.KeyPress, AddressOf number_Leave Case ValidationType.Only_Characters AddHandler txt.KeyPress, AddressOf OCHAR_Leave Case ValidationType.Not_Null AddHandler txt.Leave, AddressOf NotNull_Leave Case ValidationType.Only_Email AddHandler txt.Leave, AddressOf Email_Leave End Select End Sub Public Sub number_Leave(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Dim numbers As Windows.Forms.TextBox = sender If InStr("1234567890.", e.KeyChar) = 0 And Asc(e.KeyChar) <> 8 Or (e.KeyChar = "." And InStr(numbers.Text, ".") > 0) Then e.KeyChar = Chr(0) e.Handled = True End If End Sub Public Sub OCHAR_Leave(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) If InStr("1234567890!@#$%^&*()_+=-", e.KeyChar) > 0 Then e.KeyChar = Chr(0) e.Handled = True End If End Sub Public Sub NotNull_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Dim No As Windows.Forms.TextBox = sender If No.Text.Trim = "" Then MsgBox("This field Must be filled!") No.Focus() End If End Sub Public Sub Email_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Dim Email As Windows.Forms.TextBox = sender If Email.Text <> "" Then Dim rex As Match = Regex.Match(Trim(Email.Text), "^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,3})$", RegexOptions.IgnoreCase) If rex.Success = False Then MessageBox.Show("Please Enter a valid Email Address", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information) Email.BackColor = Color.Red Email.Focus() Exit Sub Else Email.BackColor = Color.White End If End If End Sub End Module
now lets test the module i mean lets add 4 textboxes and assign each for a validation and see whether it works !
add 4 textboxes now add labels for each like this
you can only enter numbers in textbox1
you can only enter characters in textbox2
you cannot leave textbox3 blank
you can only enter email in textbox4
now go to form_load event and add these codes
AssignValidation(Me.TextBox1, ValidationType.Only_Numbers) AssignValidation(Me.TextBox2, ValidationType.Only_Characters) AssignValidation(Me.TextBox3, ValidationType.Not_Null) AssignValidation(Me.TextBox4, ValidationType.Only_Email)
thats where we assign the textbox for a validation !!
now lets test it just debug and try entering characters in textbox1 you cannot enter , go to textbox2 try entering characters you cannot enter , go to textbox3 and without entering anything go to textbox4 a message box will popup now go to textbox4 and enter something and click into another textbox and he textbox4 will be red in color and you will get a message
thanks for reading hope this is useful ! share ! comment !
How To Make God Mode Windows 7 In C#/VB.NET
god mode is just a folder that can be used to control anything it's really easy rather than using the windows control panel because it has all the things that a user can control :) now we are going to create that folder using c# . just put these codes in button click event or form_load event
string godmode = @"D:\god.{ED7BA470-8E54-465E-825C-99712043E01C}"; Directory.CreateDirectory(godmode);
you need to add the using system.io; namespace to make the directory applicable . now you see when i debug the program and make the event work there will be a folder called god.{ED7BA470-8E54-465E-825C-99712043E01C} remember god is the folder name and this is the extension {ED7BA470-8E54-465E-825C-99712043E01C}
if you want to do it in vb.net use this codes
Dim godmode As String = "D:\god.{ED7BA470-8E54-465E-825C-99712043E01C}" Directory.CreateDirectory(godmode)
you need to add the namespace imports system.io.
now when you debug i mean when i debug i will show you the folder created in my D drive
as you see you will also see the same folder created in the directory you have given ok now i will show inside of the god folder
you have 274 files inside : how cool
i hope you enjoy this tutorial very much .
How To Make Scrolling Graphics Effect In VB.NET
hello guys :) this is something very cool and it has been created using pure graphics(2ddrawing) in vb.net . first of all i want to say you don't need work harder to understand the codes because this is created in a very simple format . ok now you see the image in the top of this post and that's how this animation works . you can add more graphics to it if your in to themebase vb.net . first you need to add a timer and i recommend you to make the form border style none for better play .
here is the codes
Imports System.Drawing.Drawing2D Public Class Form1 'Author : Mohamed Shimran 'Blog : http://www.ultimateprogrammingtutorials.blogspot.com Dim g As Graphics = Me.CreateGraphics Dim offsetvalue As Integer = 150 Dim x, y, cx, cy As Integer Dim randd As New Random Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Timer1.Start() rota = 10 x = randd.Next(0, Me.Width) y = randd.Next(0, Me.Height) cx = randd.Next(5, 10) cy = randd.Next(5, 10) End Sub Dim rota As Integer Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim g As Graphics = e.Graphics g.Clear(Color.Green) Static angle As Integer x += cx y += cy If x > Me.Width - 150 Then cx = -cx ElseIf x < 0 Then cx = -cx End If If y > Me.Height - 150 Then cy = -cy ElseIf y < 0 Then cy = -cy End If Dim G_path As GraphicsPath = New GraphicsPath() Dim rectangle As RectangleF = New RectangleF(x, y, 200, 100) Dim str_format As StringFormat = New StringFormat() str_format.Alignment = StringAlignment.Center str_format.LineAlignment = StringAlignment.Center G_path.AddRectangle(rectangle) G_path.AddString("Ultimate programming tutorials", Me.Font.FontFamily, CInt(Me.Font.Style), Me.Font.Height + 15, rectangle, str_format) angle += rota If angle > 360 Then rota = -rota ElseIf angle < 0 Then rota = -rota End If g.DrawPath(New Pen(Brushes.Black, 4), G_path) g.FillPath(Brushes.Azure, G_path) Dim matrix As Matrix = New Matrix() matrix.Translate(0, 0) matrix.RotateAt(angle, New PointF(Me.Width / 2 + (50), Me.Height / 2 - (50 / 2))) G_path.Transform(matrix) g.DrawPath(New Pen(Brushes.White, 4), G_path) g.FillPath(Brushes.Black, G_path) g.DrawPath(Pens.Black, G_path) End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Invalidate() End Sub End Class
don't do anything for the timer . just tweak the codes for your need and enjoy .
How To Connect To Mysql Database In VB.NET
hello guys , i will tell you just how to connect to mysql database in vb.net . we all know that mysql is one of the bets RDBMS which means relational database management system shortly we say DBMS which means database management system . ok now first all you need to do these things
- you need mysql server and mysql connector
- you need to add the reference mysql & mysql connector
after that with this codes you can connect to the mysql database
Imports MySql.Data.MySqlClient Public Class form1 'Author : Mohamed Shimran 'Blog : http://www.ultimateprogrammingtutorials.blogspot.com Private mysql_connect As New MySqlConnection Private Sub connect_mysql() Dim db_name As String = "Database Name" Dim db_host As String = "Database Host" Dim username As String = "Database Username" Dim password As String = "Database Password" If Not mysql_connect Is Nothing Then mysql_connect.Close() mysql_connect.ConnectionString = String.Format("server={0}; user id={1}; password={2}; database={3}; pooling=false", db_host, username, password, db_name) Try mysql_connect.Open() Catch ex As MySqlException MsgBox("Connecting To Database Error:[" & ex.Message & "]") End Try End Sub End Class
replace Database Name with your database name
replace Database Host with your database host
replace Database Username with your mysql database username
replace Database Password with your mysql database password
now debug your program if you didn't get any errors your successfully connected to your database.
How To Create Snow Falling Effect On The Form In VB.NET
I am today with an awesome effect. This is something created very simply without any classes or modules ok lets make it. First of all set your form and after that add a timer and thats all you need now just double click your form and put these.
I recommend you to use a background image or a dark background color for your form as you see in the image (top image).