IT KNOWLEDGE

IT KNOWLEDGE
BC

Saturday, July 11, 2015

Add-Remove Item from Listbox(VB.NET)

This tutorial, I combine Add items to Listbox using Textbox and Remove items from Listbox using 3 options:

  1. Remove the item that we select in Listbox
  2. Remove all items
  3. Remove items using textbox
Application Design:
  1. Form
    • Text          : Add-Remove Item From Listbox
    • Name        : AddRemoveFromListbox
    • Font Size   : 12pt
  2. Textbox(2)
    1. Textbox1
      • Name        : TextboxAdd
      • Font Size   : 12pt
    2. Textbox2
      • Name        : TextboxRemove
      • Font Size   : 12pt
  3. Button(2)
    1. ButtonAdd
      • Name        : ButtonAdd
      • Font Size   : 12pt
      • Text           : Add
    2. ButtonRemove
      • Name        : ButtonRemove
      • Font Size   : 12pt
      • Text           : Remove
  4. Groupbox
    • Text    :  GroupBoxOption
    • Name  :  Remove Option
  5. RadioButton(3)
    1. RadioButton1
      • Text: Select Item
      • Name: RadioSelectItem
    2. RadioButton2
      • Text: All
      • Name : RadioRemoveAll
    3. RadioButton3
      • Text : Select Index
      • Name : RadioSelectIndex
  6. Label
    • Name: LabelShow


Coding

Public Class AddRemoveFromListbox

    Private Sub ButtonAdd_Click(sender As Object, e As EventArgs) Handles ButtonAdd.Click
        ListBoxData.Items.Add(TextBoxAdd.Text)
        TextBoxAdd.Clear()
        TextBoxAdd.Focus()
    End Sub

    Private Sub RadioSelectItem_CheckedChanged(sender As Object, e As EventArgs) Handles RadioSelectItem.CheckedChanged, RadioRemoveAll.CheckedChanged, RadioSelectIndex.CheckedChanged
        If RadioSelectItem.Checked = True Then
            LabelShow.Text = "This will be delete selected item that you select in Listbox!"
            TextBoxRemove.Visible = False
        ElseIf RadioRemoveAll.Checked = True Then
            LabelShow.Text = "This will delete all items in Listbox!"
            TextBoxRemove.Visible = False
        Else
            LabelShow.Text = "This will delete item that same text in TextboxRemove!"
            TextBoxRemove.Visible = True
        End If
    End Sub

    Private Sub ButtonRemove_Click(sender As Object, e As EventArgs) Handles ButtonRemove.Click
        If RadioSelectItem.Checked = True Then
            ListBoxData.Items.Remove(ListBoxData.SelectedItem)
        ElseIf RadioRemoveAll.Checked = True Then
            ListBoxData.Items.Clear()
        Else
            ListBoxData.Items.Remove(TextBoxRemove.Text)
        End If
    End Sub
End Class


Search in ListBox (VB.Net)

In this tutorial, I will show you how to create an application to search data from ListBox. I'll use 4 controls to add on form:

  1. TextBox1
    • Text=""
    • Name="TxtSearch"
    • Font Size=12

  1. Button1
    • Text="Search"
    • Name="CmdSearch"
    • Font Size=12
  2. ListBox1:
    • Name:"DataListBox1"
    • Font Size=12
  3. ListBox2
    • Name="DataListBox2"
    • Font Size=12

Code
Public Class SeachListbox

    Private Sub SeachListbox_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        With DataListBox1.Items
            .Add("Business Management")
            .Add("Computer Science")
            .Add("Tourism Study")
            .Add("Law")
            .Add("Marketing")
            .Add("Electronic")
            .Add("Management")
            .Add("Engineering")
        End With
    End Sub

    Private Sub CmdSearch_Click(sender As Object, e As EventArgs) Handles CmdSearch.Click
        DataListBox2.Items.Clear()
        Dim count As Integer = (DataListBox1.Items.Count - 1)
        Dim StringA As String
        Dim StringB As String
        Dim spaceStringCounter As Integer = 0
        For i = 0 To count
            StringA = DataListBox1.Items.Item(i)
            MessageBox.Show(StringA)
            For j = 0 To StringA.Length - 1
                If spaceStringCounter >= 2 Then
                    StringB += StringA.Substring(j, 1)
                ElseIf StringA.Substring(j, 1) = Chr(32) Then
                    spaceStringCounter += 1
                End If
            Next
            If InStr(StringB, TxtSearch.Text) Then
                DataListBox2.Items.Add(DataListBox1.Items.Item(i))
            End If
            StringA = Nothing
            spaceStringCounter = 0
            StringB = Nothing
        Next
    End Sub
End Class


Friday, July 3, 2015

Change Font in Textbox and Label

This tutorial will show you how to change font(Font Name, Font Size, Font Color) in Textbox or Label using font dialog. I use one Label and one Textbox to store the text and use two difference Buttons with Click_Event to generate code.
No Control Type  Name Text Event
1 Form1 FormChangeFont Change Font
2 Label1 LabeFont I Love Visual Studio - Label
3 Textbox1 TextboxFont I Love Visual Studio - Textbox
4 Button1 ButtonLabelFont Label Font Click
5 Button2 ButtonTextboxFont Textbox Font Click


  • As you see in the images to set font on Label,  you just click on button"Label Font"  or if you want to change font in Textbox, you just click on button"Textbox Font", it will pop up the font dialog for you to customize font(name; color; size or style).
Code
Public Class FormChangeFont

    Private Sub ButtonLabelFont_Click(sender As Object, e As EventArgs) Handles ButtonLabelFont.Click
        FontDialog1.ShowDialog()
        LabelFont.Font = FontDialog1.Font
    End Sub

    Private Sub ButtonTextBoxFont_Click(sender As Object, e As EventArgs) Handles ButtonTextBoxFont.Click
        FontDialog1.ShowDialog()
        TextBoxFont.Font = FontDialog1.Font
    End Sub
End Class

Friday, May 30, 2014

Brows Image to Show in PictureBox (VB.Net)

Last tutorial, I have shown you how to invert image in PictureBox. As you see the image in PictureBox gets from using wizard by importing from any directory of computer before running code. So even thought you do not use the code, you still get the image show on your PictureBox after debugging app. Otherwise with this tutorial we will show you how to get image shows in PictureBox using code. The App has been designed as below:
No Control Type Name Text Event
1 Form1 FormBrowsImage Brows Image
2 PictureBox1 PictureBoxBrows
3 Button1 ButtonBrows Brows Click

  • To see the picture stretch fit to the picture box like this, you have to set Size Mode of picture box to StretchImage by click arrow sign on the top-right oof PictureBox and then choose StretchImage in ComboBox.

Code
Imports System.IO
Imports System.Object
Public Class FormBrowsImage
    Dim ImgPath As String
    Dim filename As String = ""
    Dim StorePath As String = Application.StartupPath & "\images\"
    Private Sub ButtonBrows_Click(sender As Object, e As EventArgs) Handles ButtonBrows.Click
        Dim oPen As New OpenFileDialog()
        oPen.Filter = "img(img(*.JPG)|*.jpg|img(*.PNG)|*.png|img(*.gif)|*.gif|All files (*.*)|*.*)"
        oPen.FilterIndex = 1
        oPen.RestoreDirectory = True
        If oPen.ShowDialog() = Windows.Forms.DialogResult.OK Then
            ImgPath = oPen.FileName.ToString()
            filename = System.IO.Path.GetFileName(ImgPath)
            If (File.Exists(StorePath & filename)) Then
                If MsgBox("The file Exists.Do you want to replace?", _
                    MsgBoxStyle.Exclamation + MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                    File.Copy(ImgPath, StorePath + filename, True)
                    PictureBoxBrows.Image = Image.FromFile(StorePath & filename)
                End If
            Else
                File.Copy(ImgPath, StorePath & filename)
                PictureBoxBrows.Image = Image.FromFile(StorePath & filename)
            End If
        End If
    End Sub
End Class


  • Note : you have to import two namespace to run this App:
    • Imports System.IO
    • Imports System.Object
















How to Invert Image in PictureBox (VB.Net)

In many developing programs allow us to develop program to edit image or customize as you want. This tutorial will show you how to develop a small application to invert image in PictureBox. I use two PictureBoxes which one is stored the base image and another one for getting result the image which is inverted.
No Control Type Name Text Event
1 Form1 FormInvertImage Inverting Image
2 PictureBox1 PictureBoxBase
3 PictureBox2 PictureBoxInvert
4 Button1 ButtonInvert Invert Click
   
  • As you see in the application screenshot, when you click on button "Invert" , you will get the image result in PictureBoxInvert. 

























How to make Font Auto Size in Textbox (VB.Net)

This tutorial will show you how to set font size of Textbox to autosize means that when you type more words in Textbox, It will set the font size to fit the Textbox which contains these text.

No Control Type Name Text Event
1 Form1 FormAutoSize AutoSize Font
2 Textbox1 TextBoxAuto Text_Changed

Code
Public Class FormAutoSizeFont
    Dim h As String
    Dim w As String
    Private Sub FormAutoSizeFont_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
        Dim orgFont As New Font(TextBoxAutosize.Font.Name, TextBoxAutosize.Font.Size, TextBoxAutosize.Font.Style)

        Dim textSize As New SizeF
        textSize = e.Graphics.MeasureString(TextBoxAutosize.Text, orgFont)
        h = textSize.Height
        w = textSize.Width
    End Sub

    Private Sub TextBoxAutosize_TextChanged(sender As Object, e As EventArgs) Handles TextBoxAutosize.TextChanged
        TextBoxAutosize.Font = New Font(TextBoxAutosize.Font.Name, 12, TextBoxAutosize.Font.Style)
        TextBoxAutosize.BorderStyle = BorderStyle.Fixed3D
        Do Until w > TextBoxAutosize.Size.Width - 5 Or TextBoxAutosize.Text = Nothing Or h > 182
            TextBoxAutosize.Font = New Font(TextBoxAutosize.Font.Name, TextBoxAutosize.Font.Size + 2, TextBoxAutosize.Font.Style)
        Loop
        TextBoxAutosize.BorderStyle = BorderStyle.None
        TextBoxAutosize.TextAlign = HorizontalAlignment.Center
        TextBoxAutosize.WordWrap = True
    End Sub
End Class










How to Convert Number to Currency (VB.Net)

This tutorial will show you how to convert number to currency using VB.Net. I use two Textboxes whic is one(TextboxNumber) for input number and another one(TextboxCurrency) for show the result of converting and I use one button(ButtonConvert) with Click_Event for process the code.
No Control type Name Text Event
1 Form1 FormConvertCurrency Convert Currency
2 Textbox1 TextboxNumber
3 Textbox2 TextboxCurrency
4 Button1 ButtonConvert Convert  Click

  • As you see in the application screenshot, I input 324 into TextboxNumber then I click on ButtonConvet, the result show in TextboxCurrency is "$324.00". To convert from number to currency like this I use "FormatCurrency()" method.
Code
Public Class FormConvertCurrency

    Private Sub ButtonConvert_Click(sender As Object, e As EventArgs) Handles ButtonConvert.Click
        TextBoxCurrency.Text = FormatCurrency(TextBoxNumber.Text)
    End Sub
End Class

















Thursday, May 29, 2014

List of 70 High Paying Google Keywords in Adsense

MESOTHELIOMA LAW FIRM 
DONATE CAR TO CHARITY CALIFORNIA 
DONATE CAR FOR TAX CREDIT 
DONATE CARS IN MA 
DONATE YOUR CAR SACRAMENTO 
HOW TO DONATE A CAR IN CALIFORNIA 
SELL ANNUITY PAYMENT 
DONATE YOUR CAR FOR KIDS 
ASBESTOS LAWYERS 
STRUCTURED ANNUITY SETTLEMENT 
ANNUITY SETTLEMENTS 
CAR INSURANCE QUOTES COLORADO 
NUNAVUT CULTURE 
DAYTON FREIGHT LINES 
HARDDRIVE DATA RECOVERY SERVICES 
DONATE A CAR IN MARYLAND 
CHEAP DOMAIN REGISTRATION HOSTING 
DONATING A CAR IN MARYLAND 
DONATE CARS ILLINOIS 
CRIMINAL DEFENSE ATTORNEYS FLORIDA 
BEST CRIMINAL LAWYER IN ARIZONA 
CAR INSURANCE QUOTES UTAH 
LIFE INSURANCE CO LINCOLN 
HOLLAND MICHIGAN COLLEGE 
ONLINE MOTOR INSURANCE QUOTES
ONLINE COLLEGES 
PAPERPORT PROMOTIONAL CODE 
ONLINE CLASSES 
WORLD TRADE CENTER FOOTAGE 
MASSAGE SCHOOL DALLAS TEXAS 
PSYCHIC FOR FREE 
DONATE OLD CARS TO CHARITY 
LOW CREDIT LINE CREDIT CARDS 
DALLAS MESOTHELIOMA ATTORNEYS 
CAR INSURANCE QUOTES MN 
DONATE YOUR CAR FOR MONEY 
CHEAP AUTO INSURANCE IN VA
MET AUTO
FORENSICS ONLINE COURSE 
HOME PHONE INTERNET BUNDLE 
DONATING USED CARS TO CHARITY
PHD IN COUNSELING EDUCATION 
NEUSON ($92.89)
CAR INSURANCE QUOTES PA 
ROYALTY FREE IMAGES STOCK 
CAR INSURANCE IN SOUTH DAKOTA 
EMAIL BULK SERVICE 
WEBEX COSTS 
CHEAP CAR INSURANCE FOR LADIES 
CHEAP CAR INSURANCE IN VIRGINIA 
REGISTER FREE DOMAINS 
BETTER CONFERENCING CALLS 
FUTURISTIC ARCHITECTURE 
MORTGAGE ADVISER 
CAR DONATE 
VIRTUAL DATA ROOMS 
AUTOMOBILE ACCIDENT ATTORNEY 
AUTO ACCIDENT ATTORNEY 
CAR ACCIDENT LAWYERS 
DATA RECOVERY RAID 
MOTOR INSURANCE QUOTES 
PERSONAL INJURY LAWYER 
CAR INSURANCE QUOTES 
ASBESTOS LUNG CANCER 
INJURY LAWYERS
PERSONAL INJURY LAW FIRM 
ONLINE CRIMINAL JUSTICE DEGREE
CAR INSURANCE COMPANIES
BUSINESS VOIP SOLUTIONS 

Sunday, May 25, 2014

Replace Text in TextBox (VB.Net)

This tutorial will show you how to replace old text with new text in only one textbox. I use only one TextBox to store text and one Button with Click_Event to generate code.
No Control type Name Text
1 Form1 FormReplaceText ReplaceText
2 TextBox1 TextBoxString
3 Button1 ButtonReplace Replace Text

  • As you see in this sample image above, when you type word "Human" in textbox"TextBoxString"  and when you click on Button "Replace Text", the textbox will show "New Repalce: Human" because I coded  "New Repalce: " & TextBoxString.Text  in program to replace.
Code

Public Class FormReplaceText

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles ButtonReplace.Click
        If TextBoxString.Text <> "" And TextBoxString.Text.Contains(TextBoxString.Text) Then
            TextBoxString.Text = TextBoxString.Text.Replace(TextBoxString.Text, "New Repalce: " & TextBoxString.Text)
        End If

    End Sub
End Class

Remove The Text At The First Line in Textbox (VB.Net)


This tutorial will how you how to remove the text at the first line in a textbox. I use one Button with Event_Click when we click the button, it will remove the first line of text in TextBoxWord.
No Control type Name Text
1 Form1 FormRemoveFirstLine Remove Text At First Line
2 TextBox1 TextBoxWord
3 Button1 ButtonRemoveFirst Remove First
 
  • As you see in the image above, when you click Button "Remove Text", it will remove word "Hello" in TextBox.
Code
Public Class FormRemoveFirstLine

    Private Sub ButtonRemoveFirst_Click(sender As Object, e As EventArgs) Handles ButtonRemoveFirst.Click
        Dim Str As String() = Split(TextBoxWord.Text, vbNewLine)
        TextBoxWord.Text = String.Join(vbNewLine, Str, 1, Str.Length - 1)

    End Sub
End Class