Click here to Skip to main content
15,906,816 members
Articles / Programming Languages / Visual Basic
Article

Tips And Links

Rate me:
Please Sign up or sign in to vote.
1.23/5 (19 votes)
22 Mar 20064 min read 41.4K   27   3
This article shows some useful tips & links for VB.Net.

Introduction

There are many useful tips & links we can find on VB.Net forum, but we miss them day by day. It is very difficult to retrieve them. My effort is to keep those tips forever. I have included new tips and answers that I provided to VB.Net forum.

 

Tips & Links -  Index

 

Forms

3. What Are The Codes For Custom Minimize & Maximize Buttons

4. How To Create Always On Top Form

5. How To Create A Form With A Transparent Background

14. How To Create A Dialog

Controls

6. How To Use Splitters                                                                [ Splitter ]

8. How To Print the Content of a RichTextBox                [ RichTextBox ]

9. Find And Replace Method For RichTextBox                [ RichTextBox ]

10. How To Handle Multiple Button Clicks                                 [ Button ]

 

File Handling

1. How To Open A File

13. How To Create A New Directory

Graphics Handling

2. How To Use Flash In VB.Net

11. How To Insert An Image Into A PictureBox At Run Time

Others

7. What Are The Conversion Functions In VB.Net

12. How To Get Day Of The Week

 

 

Red & Green - Tips            Blue & Purple - Links

 

 

Tips & Links

 

1.How To Open A FileFile Handling

You can use  this code to open a file with its associated application

System.Diagnostics.Process.Start(Filename)

 

2.How To Use Flash In VB.NetGraphics Handelling

An Example:

 

Flash MX
Create a button.
Select “Window” menu. Select “Development Panel --> Actions”
In the code editor, type this

on (release) {<BR>fscommand ("Button1");<BR>}

Save the movie. (“Untitled-1.fla”)
Select “Control” menu and Select “Test Movie”
Flash will create (“Untitled-1.swf”)
Exit from Flash.

VB.Net
Right click on the tool box. Select “Add/Remove Items…”. Select “COM Components”
Select “Shockwave Flash Object”. Click OK
Draw it on the form
Name it “SF1”

Right click on “SF1” and select “Properties”
Type the path to “Untitled-1.swf” in the “Movie URL” textbox.
Click OK

Double Click on SF1 ( go to Code Editor )
Select “FS Command” from Procedure List Box
Type this

Private Sub SF1_FSCommand(ByVal sender As Object, ByVal e As AxShockwaveFlashObjects.DShockwaveFlashEvents_FSCommandEvent) Handles SF1.FSCommand
If e.command = "Button1" Then
MsgBox("it works")
End If
End Sub


Run the program
Click on Button1

 

3.What Are The Codes For Custom Minimize & Maximize ButtonsForms

Me.WindowState = FormWindowState.Minimized

Me.WindowState = FormWindowState.Maximized

 

4.How To Create Always On Top FormForms

Simple, set form's Topmost property to true

 

5.How To Create A Form With A Transparent BackgroundForms

Set form's TransparancyKey property to forms background color, or you can create ghostly forms by changing the Opaque property

(0 -100)

 

6.How To Use SplittersControls [ Splitters ]

An Example:

 

1. Draw a panel on the form

2. Draw a textbox on the panel ( TextBox1.width is ( 1/2 Panel1.width ) )

3. Set TexBox1's Dock property to Left

4. Draw a splitter on the panel and set its Dock property to Left

5. Run Your Application

6. Now  resize your TextBox1 by dragging the splitter

 

7.What Are The Conversion Functions In Visual BasicOthers

CBool  : Converts to Bool

CByte  : Converts to Byte

CChar  : Converts to Char

CDate  : Converts to Date

CDbl     : Converts to Double

CDec    : Converts to Decimal

CInt     : Converts to Int

CLng    : Converts to Long

CObj      : Converts to Object

CShort  : Converts to Short

CSng     : Converts to Single

CStr      : Converts to String

 

8.How To Print the Content of a RichTextBoxControls [ RichTextBox ]

http://support.microsoft.com/default.aspx?scid=kb;en-us;811401

 

9.Find And Replace Method For RichTextBoxControls [ RichTextBox ]

http://www.codeproject.com/useritems/findandriplace_rtb.asp

 

10.How To Handle Multiple Button ClicksControls [ Buttons ]

If You have two or more buttons you can handle them like this

 

Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, _ Button2.Click,Button3.Click

If sender Is Button1 Then

action1

ElseIf sender Is Button2 Then

action2

ElseIf sender Is Button3 Then

action3

End If

End Sub

 

11.How To Insert An Image Into A Picture Box At Run Time Graphics Handling

PictureBox1.Image = Image.FromFile(filename)

 

12.How To get Day Of The Week Others

'If Date is 24 March 2006

Dim strDayOfTheWeek As String

Dim intDayOfTheWeek As Integer

strDayOfTheWeek = Now.DayOfWeek.ToString ' returns Friday

intDayOfTheWeek = Now.DayOfWeek ' returns 5

 

13.How To Create A New Directory File Handling

Imports System.IO

.

.

Directory.CreateDirectory(Path) 'Example Directory.CreateDirectory( "C:\myDirectory" )

 

14.How To Create A Dialog Forms

VB.Net 2003

1. Create a new form (Form2)

2. Create two buttons

3. Set these properties

   Button1 : Name = OK_Button , Caption = OK

   Button2 : Name = Cancel_Button , Caption = Cancel

   Form2 :   Name = Dialog1 , FormBorderStyle = FixedDialog , MazimizeBox = False , MinimizeBox = False , AcceptButton = OK_Button                 , CancelButton = Cancel_Button

 

VB.Net 2005

Click Add New Items button on the standard toolbar

Select Dialog and Click Add

 

Now You Can Use Your Dialog in Form1

Dim myDialog As New Dialog1

If myDialog.ShowDialog = Windows.Forms.DialogResult.OK Then

action

End If

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Sri Lanka Sri Lanka
I'm a student of University of Colombo School of Computing
I'm also a
Sun Certified Java Programmer

Comments and Discussions

 
GeneralMy vote of 5 Pin
Global Analyser3-Nov-10 7:03
Global Analyser3-Nov-10 7:03 
GeneralSuperb. Pin
salimsm5-Aug-07 9:33
salimsm5-Aug-07 9:33 
GeneralRe: Superb. Pin
Chatura Dilan28-Sep-07 17:41
Chatura Dilan28-Sep-07 17:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.