Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Sunday, August 7, 2011

VB-87 : Employee details

==================================================================================

Before going to do any Database Program ,Click here to  understand Database Concepts thoroughly.


That is , Creating Database within VB Platform


==================================================================================

Write a program in VB to find out details about software engineers working in a S/W company. Details are stored in a database with Emp_Id as primary key. You need to store the following information in database:
  1. Emp_ID
  2. Name
  3. Edu_Qualification
  4. Year_Of_Experience
  5. Area_Of_Specialisation

(A)Program Design : 



(B) Property(Controls Used) :
  • 5 Labels and 5 Text Boxes
  • 2 Command Buttons (Save & Exit)

(C) Attaching Code to the Object :



Public cnn As ADOdb.Connection
Public rs As ADOdb.Recordset
Dim search As String
Private Sub Command1_Click()
Call createConnection

With rs
.ActiveConnection = cnn
.LockType = adLockOptimistic
.CursorType = adOpenDynamic
.Source = "Select*From emp"
.Open

End With
rs.AddNew

rs.Fields(0) = CInt(Text1.Text)
rs.Fields(1) = Text2.Text
rs.Fields(2) = Text3.Text
rs.Fields(3) = Text4.Text
rs.Fields(4) = Text5.Text

rs.Update
rs.Close
Call clear
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Set rs = New ADOdb.Recordset
End Sub
Private Sub createConnection()
Set cnn = New ADOdb.Connection
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\emp.mdb;Persist Security Info=False"
.CursorLocation = adClient
.Open
End With
End Sub
Private Sub clear()
Text1.Text = ""
Text2 = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
End Sub



(D) Output :

(May be some error if the path given is not correct..Then , we will receive an error message as "Use-Defined type not defined.".and it may point to the first line : cnn As ADOdb.Connection)

(E) Errors :

If found any errors while running your VB program, or want to put your comment about any  program , please click Comment section , to post.

      • ====================================================================
        Back to Home   &  VB
    ==========================================================

    VB-86 : Find average sales

    Write a VB program to find the average sales. Read sales from January to June then find average of them.

    (A)Program Design : 


    (B) Property(Controls Used) :
    • 6 Labels and 6 textboxes (Name Text1 to 6 respectively)
    • Two Command Buttons (Find Average and Exit)
    • One TextBox to display average (Text7)
    (C) Attaching Code to the Object :

    Dim jan, feb, mar, apr, may, june
    Dim avg As Double
    Private Sub Command1_Click()
    jan = CInt(Text1.Text)
    feb = CInt(Text2.Text)
    mar = CInt(Text3.Text)
    apr = CInt(Text4.Text)
    may = CInt(Text5.Text)
    june = CInt(Text6.Text)
    avg = (jan + feb + mar + apr + may + june) / 6
    Text7.Text = avg
    End Sub
    Private Sub Command2_Click()
    Unload Me
    End Sub


    (D) Output :


    (E) Errors :

    If found any errors while running your VB program, or want to put your comment about any  program , please click Comment section , to post.


    ====================================================================
      ===========================================================


    VB-85 : Moving from TextBox to ListBox

    Type text in TextBox and after pressing Send to ListBox, text should be displayed in the ListBox.


    (A)Program Design : 




    (B) Property(Controls Used) :
    • TextBox
    • ListBox
    • 2 Command Buttons (Send to ListBox and Exit)
    (C) Attaching Code to the Object :




    Private Sub Command1_Click()
    Dim data As String
    data = Text1.Text
    List1.AddItem (data)
    Text1.Text = ""
    End Sub
    Private Sub Command2_Click()
    Unload Me
    End Sub


    (D) Output:



    Refer these also :
    Adding items in a listbox/Combobox (Throug...
    Removing items in a listbox/Combobox (Thro...
    Selecting items from a listbox/Combobox (T...
    Moving items between listbox/Combobox (Th...


    (E) Errors :

    If found any errors while running your VB program, or want to put your comment about any  program , please click Comment section , to post.

    ====================================================================
      ===========================================================

    VB-84 : Read your DOB and find your age.


    Write a program in VBto read your Date Of  Birth (DOB) , take current date from the system and then find your age  :
    Refer Application to calculate your age also.



    To set Date, we need a controll called DtPicker.
    To add DtPicker , select Project--> Components--> Microsoft Window common control-2.6.0

    (A)Program Design : 


    (B) Property(Controls Used) :
    • DtPicker
    • One Command Button (Find Age)
    • 3 TextBoxes (To display Years,Months and Days)
    (C) Attaching Code to the Object :

    Private Sub Command1_Click()
    Dim dob, today, y, m, d
    dob = CDate(DTPicker1)
    today = Now()

    y = DateDiff("yyyy", dob, today)
    Text1.Text = y

    m = DateDiff("m", dob, today) Mod 12
    Text2.Text = m

    d = DateDiff("d", dob, today) - ((y - 1) * 365) - (m * 30)
    Text3.Text = d

    End Sub


    (D) Output :


    (E) Errors :

    If found any errors while running your VB program, or want to put your comment about any  program , please click Comment section , to post.


        • ====================================================================
          Back to Home   &  VB
      ===========================================================

      VB-83 : Total words,Characters,sentence,length of strings

      Write an event procedure and develop an application to intake 2 strings text , Concatenate them and find total number of words,total number of characters (between A to Z) , total number of sentences and total length of the resultant text.


      Click to see a simple program of this type The number of digits in the entered Number...


      Refer  Resultant Length of 2 concatenated Strings...and  Occurrence of a String also.



      (A)Program Design : 






      (B) Property(Controls Used) :
      • 7 labels for TextBoxes
      • 3 TextBoxes (Text1,2 and resultant text)
      • 4 TextBoxes (Name Text4,5,6 & & respectively , to get the results
      • 2 Command Buttons Find & Cancel (Command 1 & 2 are names)

      (C) Attaching Code to the Object :





      Private Sub Command2_Click()
      Unload Me
      End Sub


      Private Sub Command1_Click()
      Dim str As String
      Dim wordcount, sentencecount, charcount
      wordcount = 1
      sentencecount = 1
      charcount = 0
      str = Text1.Text + Text2.Text
      For i = 1 To Len(str)
         If Mid(str, i, 1) = " " Then 'include a single space inside quotes
         wordcount = wordcount + 1
         Else
              If Mid(str, i, 1) = "." Or Mid(str, i, 1) = "?" Then
              sentencecount = sentencecount + 1
              Else
                  If (Asc(Mid(str, i, 1)) >= 65 And Asc(Mid(str, i, 1)) <= 90) Or (Asc(Mid(str, i, 1)) >= 97 And Asc(Mid(str, i, 1)) <= 122) Then
                  charcount = charcount + 1
                  End If
              End If
          End If
      Next
      Text3.Text = str
      Text4.Text = wordcount
      Text5.Text = charcount
      Text6.Text = Len(str)
      Text7.Text = sentencecount
      End Sub




      (D) Output :


      (E) Errors :

      If found any errors while running your VB program, or want to put your comment about any  program , please click Comment section , to post.
          • ====================================================================
            Back to Home   &  VB
        ===========================================================

        VB-82 : Basic Mathematical functions

        Develop a small application to use the basic mathematical functions on the numbers.
        The user interface of  the application should appear as the given figure:


        Refer  Simple Programs(3) to get an idea about Calculation



        Sum
        Subtract
         Multiply
        Divide
         Square
        Cube
        sin N1
        cos N1
        N1
        N2
        èPress

                  Answer
             Cancel




        When square like operations is selected , the N2 should become inactive. You should use horizontal scroll bar to set the maximum values of N1 and N2.


        Refer Simple Calculator also.



        (A)Program Design : 





        (B) Property(Controls Used) :
        • 4 Labels for proper headings
        • 3 TextBoxes
        • 2 Command Buttons ( ==>> : Command1 and Cancel :Command2)
        • 9 OptionButtons
        • Horizontal ScrollBar

        (C) Attaching Code to the Object :


        Private Sub Command2_Click()
        Unload Me
        End Sub
        Private Sub Command1_Click()
        Dim n1, n2
        If Text1.Text <> "" Then
            n1 = CInt(Text1.Text)
        End If
        If Text2.Text <> "" Then
            n2 = CInt(Text2.Text)
        End If
        If Option1.Value = True Then
           Text3.Text = n1 + n2
        Else
            If Option2.Value = True Then
            Text3.Text = n1 - n2
            Else
                If Option3.Value = True Then
                Text3.Text = n1 * n2
                Else
                    If Option4.Value = True Then
                      If n2 <> 0 Then
                        Text3.Text = n1 / n2
                      Else
                        Text3.Text = "Error"
                      End If
                    Else
                        If Option4.Value = True Then
                        Text3.Text = n1 Mod n2
                        Else
                            If Option6.Value = True Then
                            Text3.Text = n1 * n2
                            Else
                                If Option7.Value = True Then
                                Text3.Text = n1 * n1 * n1
                                Else
                                    If Option8.Value = True Then
                                    Text3.Text = Math.Sin(n1)
                                    Else
                                        If Option9.Value = True Then
                                        Text3.Text = Math.Cos(n1)
                                        End If
                                    End If
                                End If
                            End If
                        End If
                    End If
                End If
            End If
        End If
        End Sub
        Private Sub Option1_Click()
        Option2.Value = False
        Option3.Value = False
        Option4.Value = False
        Option5.Value = False
        Option6.Value = False
        Option7.Value = False
        Option8.Value = False
        Option9.Value = False
        Text2.Enabled = True
        End Sub
        Private Sub Option2_Click()
        Option1.Value = False
        Option3.Value = False
        Option4.Value = False
        Option5.Value = False
        Option6.Value = False
        Option7.Value = False
        Option8.Value = False
        Option9.Value = False
        Text2.Enabled = True
        End Sub
        Private Sub Option3_Click()
        Option1.Value = False
        Option2.Value = False
        Option4.Value = False
        Option5.Value = False
        Option6.Value = False
        Option7.Value = False
        Option8.Value = False
        Option9.Value = False
        Text2.Enabled = True
        End Sub
        Private Sub Option4_Click()
        Option1.Value = False
        Option2.Value = False
        Option3.Value = False
        Option5.Value = False
        Option6.Value = False
        Option7.Value = False
        Option8.Value = False
        Option9.Value = False
        Text2.Enabled = True
        End Sub
        Private Sub Option5_Click()
        Option1.Value = False
        Option2.Value = False
        Option3.Value = False
        Option4.Value = False
        Option6.Value = False
        Option7.Value = False
        Option8.Value = False
        Option9.Value = False
        Text2.Enabled = True
        End Sub
        Private Sub Option6_Click()
        Text2.Enabled = False
        Option1.Value = False
        Option2.Value = False
        Option3.Value = False
        Option4.Value = False
        Option5.Value = False
        Option7.Value = False
        Option8.Value = False
        Option9.Value = False
        End Sub
        Private Sub Option7_Click()
        Text2.Enabled = False
        Option1.Value = False
        Option2.Value = False
        Option3.Value = False
        Option4.Value = False
        Option5.Value = False
        Option6.Value = False
        Option8.Value = False
        Option9.Value = False
        End Sub
        Private Sub Option8_Click()
        Text2.Enabled = False
        Option1.Value = False
        Option2.Value = False
        Option3.Value = False
        Option4.Value = False
        Option5.Value = False
        Option6.Value = False
        Option7.Value = False
        Option9.Value = False
        End Sub
        Private Sub Option9_Click()
        Text2.Enabled = False
        Option1.Value = False
        Option2.Value = False
        Option3.Value = False
        Option4.Value = False
        Option5.Value = False
        Option6.Value = False
        Option7.Value = False
        Option8.Value = False
        End Sub



        (D) Output :


        (E) Errors :


        If found any errors while running your VB program, please click Comment section.

        ====================================================================
        =========================================================