Friday, May 2, 2014

Visual Basic Tutorial | How to Make a Folder/Directory in Visual Basic 2010Yo for Beginners

5:57 AM 0
Hello everyone, last tutorial we learn how to make a specific file using visual basic 2010. Today we are going to make folder or directory.

According to wikipedia.org - In computing, a directory is a file system cataloging structure which contains references to other computer files, and possibly other directories. On many computers directories are known asfolders, catalogs (used on the Apple II, the Commodore 128 and some other early home computers as a command for displaying disk contents - the filesystems used by these DOS did not support hierarchal directories), or drawers to provide some relevancy to a workbench or the traditional office file cabinet. On Microsoft Windows, the terms folder and directory are used interchangeably

How can I make a folder or directory in visual basic

Creating a directory in visual basic is simple as ABC and 123, the code you need is just a simple 1 line code..

If you want to create a static directory with fix folder name and place to save in, you will need this code.

My.Computer.FileSystem.CreateDirectory("C:\myfolder")
You can add a message box for notification when the folder is created. note that this is a fixed folder with file name and a C:\ drive where the folder will be saved..

If you want to create a dynamic folder with user defined folder name and drive to save it you can modify the code, but before this you must add some controls. Add the following controls to your project.

1 Combobox 'list all the drives where you want to save the folder
1 Textbox 'this will be used to type the folder name
1 Button 'this will serve as the main command to create the folder

Your program must look like this

Once all the controls have been placed and aligned, you can now start writing this code at the button1_click event.

 My.Computer.FileSystem.CreateDirectory(ComboBox1.Text + Textbox1.Text)
you can also add a message box for notification whether the folder was created.

Thursday, May 1, 2014

Visual Basic Tutorial | How to Make File (.txt or .docx) in Visual Basic 2010

5:22 AM 0
Hey, I have a new tutorial to share to you guys, this tutorial is very exciting and good practice for newbies in programming.

Today we are going to work with files, different types of files, this tutorial is all about making file in visual basic 2008 and above versions. (I do not know if this codes will worked at vb6, well I guess it's worth a try)

Now, we all know that file is very important in digital world. OS and other programs are made out of file that contains a series of codes and instructions.

There are lots of common files that can be made in visual basic. I will give you some of the common files used nowadays.

Here are samples of common Text Files

.docMicrosoft Word Document
.docxMicrosoft Word Open XML Document
.logLog File
.msgOutlook Mail Message
.odtOpenDocument Text Document
.pagesPages Document
.rtfRich Text Format File
.texLaTeX Source Document
.txtPlain Text File
.wpdWordPerfect Document
.wpsMicrosoft Works Word Processor Document

and here are some of the common Data Files 

.csvComma Separated Values File
.datData File
.gbrGerber File
.gedGEDCOM Genealogy Data File
.ibooksMulti-Touch iBook
.keyKeynote Presentation
.keychainMac OS X Keychain File
.ppsPowerPoint Slide Show
.pptPowerPoint Presentation
.pptxPowerPoint Open XML Presentation
.sdfStandard Data File
.tarConsolidated Unix File Archive
.tax2012TurboTax 2012 Tax Return
.vcfvCard File
.xmlXML File

In visual basic we can make a file that is listed above, we just need a simple code yet powerful to create files.

How to make a static file?

If you want to create a static file with fix file name and fix location where to save it you will need to write this code.

Dim path as String = "C:\MyFile.txt"Dim FS as FileStream = File.Create(path)Msgbox(path + " created")

As you notice the file name and the location of the file to be created are programmatically fixed as "C:\MyFile.txt". This is the very basic code on how to create a static file.

How to make a Dynamic file?

If you are planning to create a file that you want to save it on a specific drives, put a specific file name and put a specific file extension you will need some additional controls on your project. Put this controls in your program.

1 ComboBox = List all the drives where to save the file
1 ComboBox = List all the specific file extensions 
1 Textbox = Field to type a specific file name for new file to be created
1 Button = Set as Create File

How to edit items on combo box?

Once all the controls are set and ready for coding, select 1 combo box and you will notice that there is a small arrow on top of it. Click it and select 'Edit Items', Now each item must be separated by new line, after typing an item just press Enter to go to the next line.

now that all the controls are ready, you will need the following code to create or make a dynamic file types in visual basic.

Dim path as string = Combobox1.text + Textbox1.text + Combobox2.textDim FS as FileStream = File.Create(path)Msgbox(path + " Has been created")
Visual Basic Tutorial | How to Make File (.txt  or .docx) in Visual Basic 2010
Your program must look like this


Note that this code must be written into the button1_click event that serve as the 'Create File' button.

To check that the file has been created, browse on the drive where you set as the location of the file you created.

I have uploaded a video tutorial on how you can make a file with visual basic 2010 for beginners just to get you some example or what is this tutorial about.

Watch Video Tutorial




Tuesday, April 29, 2014

Visual Basic Tutorial - How to use Select Case in Visual Basic 2008-2010 for Beginners

5:48 AM 0
Hey guys today we are going to use another usable condition can be used to run multiple expressions, this statements is the 'Select Case Statement'..

Select Case - Runs one of several groups of statements, depending on the value of an expression. This statement can handle 1 to 10 or 10 to thousand statements or depending to the expression want by the programmers.

The Basic Structure of Select Case Statement, this statement require you to declare a variable to be used. See Parts

Select [ Case ] testexpression 

 [ Case expressionlist [ statements ] ] 
 [ Case Else [ elsestatements ] ]
End Select

Parts of Select Case Statement from support.microsoft.com

Testexpression - Required. Expression. Must evaluate to one of the elementary data types (Boolean, Byte, Char,Date, Double, Decimal, Integer, Long, Object, SByte, Short, Single, String, UInteger, ULong, and UShort).

Expressionlist - Required in a Case statement. List of expression clauses representing match values fortestexpression. Multiple expression clauses are separated by commas. Each clause can take one of the following forms: 

• expression1 To expression2 
• [ Is ] comparisonoperator expression 
• expression

Use the To keyword to specify the boundaries of a range of match values for testexpression. The value of expression1 must be less than or equal to the value of expression2.


Use the Is keyword with a comparison operator (=, <>, <, <=, >, or >=) to specify a restriction on the match values for testexpression. If the Is keyword is not supplied, it is automatically inserted before comparisonoperator.


The form specifying only expression is treated as a special case of the Is form wherecomparisonoperator is the equal sign (=). This form is evaluated as testexpression = expression.

The expressions in expressionlist can be of any data type, provided they are implicitly convertible to the type of testexpression and the appropriate comparisonoperator is valid for the two types it is being used with.

statements - Optional. One or more statements following Case that run if testexpression matches any clause in expressionlist.

elsestatements - One or more statements following Case Else that run if testexpression does not match any clause in the expressionlist of any of the Case statements.

End Select - Terminates the definition of the Select...Case construction. 

Now that you already know the basic parts of the Select Case Statement, we will going to create a sample project that will use Select Case Statement.

Create a New Project and Name it [Age]

This program will determine whether the inputted age is Infant, Teen or Adult.

Controls you need

1 textbox = type desired age when program is executed
1 label = rename it to "type age"
1 button = rename it to "identify age"

The Code: Make sure you embed this code to the 'identify age' button_click event.

Dim age as integer = Textbox1.Text
    Select Case age
       Case 0 To 10
            Msgbox("This is Infant")
       Case 15 To 19
            Msgbox("This is Teen")
       Case 20 To 90
            Msgbox("This is Adult")
    End Select
After you write this code to your project try to run it and try if it works.. 

I have a made a video tutorial on this program on how you can do this project. 

Watch Video Tutorial



Wednesday, April 23, 2014

Visual Basic Tutorial : How to Add/Delete Record to MS Access Database Using Visual Basic 2010

6:39 AM 1
The most popular visual basic programming is about the ability of the program to save records in to the database. 

With this database you can save thousands of records at once. In visual basic programming, the common database software used in visual basic is the Sql Database and Microsoft Access.. Though the programmers of both software made an update, still the methods of adding new records to database does not effect during the update.

According to mdsn.microsoft.com the with statement is:


Executes a series of statements that repeatedly refer to a single object or structure so that the statements can use a simplified syntax when accessing members of the object or structure. When using a structure, you can only read the values of members or invoke methods, and you get an error if you try to assign values to members of a structure used in a With...End With statement. -credits to microsoft.com

In our case we are using MS Access as our database record storage together with this tutorial..

Today, we are going to use two different software to make an exciting project, these two software are Visual Basic and Microsoft Access. 

Before we begin, let us go to the basic codes of saving new records to database...

The code we are going to use is the [With... End With Statement]


This is the basic structure of the with statement..
With objectExpression

.[ statements ]

End With
Let us start a small program that will allow us to add new record on ms database file.

I have a video tutorial with the whole process from creating a new project to database creation and connecting it to visual basic and coding to make it work..

Written Tutorial.. Steps

Step 1. Make new Database in ms access... Then Save it
Step 2. Open Visual Basic... Create new Project.
Step 3. Save the project.
Step 4. Copy the Saved Database you create on step 1 and navigate on this folder..


C:\Users\YourUsername\Documents\Visual Studio 2010\Projects\[saved project on step 3]\[saved project on step 3]\bin

Step 5. Once you are in the bin folder of the program you saved before, Paste the database there.. this is important for locating the database file during the coding phase.

Step 6. Watch this tutorial on how to connect the database to visual basic.





Assuming that you already connected the database to visual basic. We are going to add the code to save button to add new record to database..

Now that all the connection is all set, watch this video on how to insert and delete record on ms access database using visual basic 2008 - 2010.




Tuesday, April 22, 2014

Visual Basic Tutorial : How to Add Custom Form Theme and Skins in Visual Basic

6:13 PM 4
In programming, it is necessary to make a program with custom designs and functionality. Today, I am going to show you a common things used by programmers.. and its about on "HOW TO ADD CUSTOM THEME AND SKINS TO A FORM IN VISUAL BASIC".. 

The process is simple as ABC, you'll just need this Theme Collection to select the theme or skins you want to use in your forms and controls.. 

As you can see, there are bunch of theme to be used and as custom skin for your programs and forms. Each theme has a custom controls like, Textbox, Buttons, Labels and other common controls.

I recorded a video demonstration of the custom skins collection of this archive..



Now that you know how it worked and its skin collections. We are going to proceed now to the tutorial on how you can add this to your project.

Step 1. Open Visual Studio
Step 2. Create New Project
Step 3. Open Theme Archive Manager (Click to Download)
Step 4. Select the desired theme/skin
Step 5. Click "View Code" on Theme Collection
Step 6. Click the Code to Highlight and Copy it to the Clipboard
Step 7. Go to your visual basic project and add new Class.vb
Step 8. Remove all the Class.vb codes and Paste the copied code to the class.vb
Step 9. Build Project (and when its done)
Step 10. Go to Form1 GUI and click Toolbox, you will now see the custom skins and controls and its ready to use.

If you found the written tutorial difficult to understand, I uploaded a step-by-step video tutorial on how you can add custom theme/skins on forms in visual basic.net

Watch Tutorial (Please Watch it in large player mode)

Sunday, April 20, 2014

Visual Basic Tutorial : How to Use vbStrConv to Convert Text into Upper, Proper and Lower Case

6:28 PM 0
Hi folks.. welcome to another exiting visual basic tutorial.. today we are going to convert text in textbox into Upper, Lower and Proper case using this common code in visual basic..

First we will discuss what is the vbStrConv : credits to msdn.microsoft.com

The Conversion argument settings are:
Enumeration member
Description
VbStrConv.None
Performs no conversion
VbStrConv.LinguisticCasing
Uses linguistic rules for casing, rather than File System (default). Valid with VbStrConv.UpperCase and VbStrConv.LowerCase only.
VbStrConv.UpperCase
Converts the string to uppercase characters.
VbStrConv.LowerCase
Converts the string to lowercase characters.
VbStrConv.ProperCase
Converts the first letter of every word in string to uppercase.
VbStrConv.Wide*
Converts narrow (half-width) characters in the string to wide (full-width) characters.
VbStrConv.Narrow*
Converts wide (full-width) characters in the string to narrow (half-width) characters.
VbStrConv.Katakana**
Converts Hiragana characters in the string to Katakana characters.
VbStrConv.Hiragana**
Converts Katakana characters in the string to Hiragana characters.
VbStrConv.SimplifiedChinese*
Converts Traditional Chinese characters to Simplified Chinese.
VbStrConv.TraditionalChinese*
Converts Simplified Chinese characters to Traditional Chinese.

The syntax is:

TextBox2.Text = StrConv(TextBox1.Text, VbStrConv."desired case")

Further Explanation:

Textbox2 is the display result..
Textbox1 is the input text field...

Program Logic:

Every text typed into the textbox1 will be converted into the selected case and the converted result will display into the Textbox2.

Controls you need for this program:

2 Textbox (textbox1 = input) and (textbox2 = output)

3 RadioButton (Rename into the following:
  Radio1 = Convert to UPPER
  Radio2 = Convert to Proper
  Radio3 = Convert to lower

1 Button

Now we will use this code to button1 click event.. this code contains multi-line if statement syntax.

The conversion Code:

        If RadioButton1.Checked Then
            TextBox2.Text = StrConv(TextBox1.Text, VbStrConv.Uppercase)

        ElseIf RadioButton2.Checked Then
            TextBox2.Text = StrConv(TextBox1.Text, VbStrConv.ProperCase)

        ElseIf RadioButton3.Checked Then
            TextBox2.Text = StrConv(TextBox1.Text, VbStrConv.Lowercase)

        End If

Note: the following code must be inserted into the Private Sub Button1_Click.. 

I uploaded a video tutorial on how you can do this..

Watch Tutorial




Saturday, April 12, 2014

Visual Basic Tutorial : How to Compute Numbers In Visual Basic [Mathematical Operations] With Textboxes

6:20 PM 0
Hi all, in this tutorial we will tackle about mathematical computing in vb.net (visual basic 2010).. We all know that computers works with the same basic principles.. Computers are built decades ago to use for powerful computing.. A single characters in your keyboards are represented as binaries as zeros and one ("0 1").

Developing Simple or Advance Calculators in visual basic are made easier using the batch of codes to be written under every controls..

Before we start let's first take an overview on what are the operators to be used in computing on visual basic..

The following is a table of arithmetic operators in Visual Basic.

SymbolName
+Addition
-Subtraction
*Multiplication
/Division
\Integer Division
ModModulo
^Exponentiation

Let's make a simple calculator...

Things you need:

1 Button = Compute
1 Textbox = Num1
1 Textbox = Num2
1 Textbox = Total
4 Radiobuttons = (operators +, -, *, /)


The code Template
total = num1 + num2 for addition

total = num1 - num2 for subtraction
total = num1 * num2 for multiplication
total = num1 / num2 for division


Design it like this...
How to Compute Numbers In Visual Basic [Mathematical Operations] With Textboxes

Now for coding as I said last time we will use the [multi-line syntax IF Statement] that is why we use radioboxes for condition making... Learn Multi-Line IF Statement Syntax on this section..

Now lets insert a code for our calculator..

Double click the Button1 and use this code..

Note* from the design Do not change the name of the controls to avoid errors..

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

  
        If RadioButton1.Checked Then
            TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)

        ElseIf RadioButton2.Checked Then
            TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)

        ElseIf RadioButton3.Checked Then
            TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)

        ElseIf RadioButton4.Checked Then
            TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text)

        End If
End Sub

Based from the code above you can see that it is very simple to analyze how it works, it is very self explanatory as you read it.. Now try it yourself and experiment use other controls for your own calculator..

Watch My Video Tutorial


Incoming search terms:

how to compute in visual basic
how to compute in visual basic using textbox1 and textbox2