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, June 5, 2011

VB-22 : Moving items between listbox/Combobox (Through Program)



Add items to the textbox.Then move themt, to another list/combo box.

A)   Property :

       
Listbox  : NAME-List1,LIST-(Blank)
Listbox  : NAME-List2,LIST-(Blank)
Textbox : NAME-Text1,Text- (Blank)
CommandButton-NAME- Command3,Caption-Add
CommandButton-NAME- Command1,Caption- è
CommandButton-NAME- Command2,Caption- ç





B)   Attaching Code to the Object :

        
Private Sub Command1_Click()
List2.AddItem List1.List(List1.ListIndex)
List1.RemoveItem List1.ListIndex
End Sub

Private Sub Command2_Click()
List1.AddItem List2.List(List2.ListIndex)
List2.RemoveItem List2.ListIndex
End Sub

Private Sub Command3_Click()
List1.AddItem Text1.Text
End Sub





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

VB-21 : Selecting items from a listbox/Combobox (Through Program)



Our selected item will store in the list index of combo box.
     
A)   Property :
ComboBox : NAME- Combo1,TEXT-(Blank)
Textbox : NAME-Text1,Text- (Blank)
CommandButton-NAME- Command1,Caption-Add
CommandButton-NAME- Command3,Caption-Select






     B)   Attaching Code to the Object :
  
    
Private Sub Command1_Click()
Combo1.AddItem Text1.Text
End Sub

Private Sub Command3_Click()
st = Combo1.List(Combo1.ListIndex)

MsgBox (st)
End Sub




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

VB-20 : Removing items in a listbox/Combobox (Through Program)

Removing items in a listbox/Combobox (Through Program)




(A)        When we click the Remove button, the added items will remove from the list/combo box starting from 0th position.
(If we want to remove items as per our choice, then refer the next program)




     A)   Property :
ComboBox : NAME- Combo1,TEXT-(Blank)
Textbox : NAME-Text1,Text- (Blank)
CommandButton-NAME- Command1,Caption-Add
CommandButton-NAME- Command2,Caption-Remove



 B)   Attaching Code to the Object :

Private Sub Command1_Click()
Combo1.AddItem Text1.Text
End Sub

Private Sub Command2_Click()
Combo1.RemoveItem 0
End Sub



Note : Combo1.RemoveItem 0 èè The items in the list/combo box are stored as index,starting from 0,1,2,3…….etc.

That is,first item is in 0th position , second item is in 1st position etc.

========================================================================
(B)        If we want to remove items as per our choice from the list/combo box, then follow the below given steps..

(It’s your Homework :)) )
========================================================================



Back to Home   &  VB

VB-19 : Adding items in a listbox/Combobox (Through Program)


(A)        When we click the add button, “Hello “will add to the list as per our click.


     A)   Property :
Listbox  : NAME-List1,LIST-(Blank)
CommandButton-NAME- Command1,Caption-Add





     B)   Attaching Code to the Object :

Private Sub Command1_Click()
List1.AddItem”Hello”
End Sub



=========================================================================
(B)        If we want to add items to the listbox as per our choice, then follow the code given below:

     A)   Property :

Listbox  : NAME-List1,LIST-(Blank)
Textbox : NAME-Text1,Text- (Blank)
CommandButton-NAME- Command1,Caption-Add



     B)   Attaching Code to the Object :


Private Sub Command1_Click()
List1.AddItem Text1.Text
End Sub



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

C) . Adding items in a ComboBox(Through Program)

     A)   Property :

ComboBox : NAME- Combo1,TEXT-(Blank)
Textbox : NAME-Text1,Text- (Blank)
CommandButton-NAME- Command1,Caption-Add




     B)   Attaching Code to the Object :


Private Sub Command1_Click()
Combo1.AddItem Text1.Text
End Sub



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

VB-18 : Changing text alignment using Timer



A)   A) Property :

Timer : NAME-Timer1, INTERVAL-2000
Textbox : NAME-Text1, TEXT-Hai




(The Timer will not appear on the output Screen )

B) B)   Attaching Code to the Object :

      
Dim flag As Integer
Private Sub Timer1_Timer()
If flag = 1 Then
Text1.Alignment = 0
flag = 0
Else
Text1.Alignment = 0
flag = 1
End If
End Sub


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

Back to Home   &  VB

VB-17 : Colour changing using Timer


Refer Changing Color as per the entered Number also.


(A)        When we give 2000 as intervals for the first and second timer, the 2 timers will work in each 2 seconds by changing the text color in the textbo


A)   Property :


         Timer : NAME-Timer1, INTERVAL-2000
         Timer : NAME-Timer2, INTERVAL-2000
        Textbox : NAME-Text1, TEXT-Hai




B)  Attaching Code to the Object :

  
            Private Sub Timer1_Timer()
           Text1.ForeColor = &HFF0000
           End Sub

           Private Sub Timer2_Timer()
           Text1.ForeColor = 255
          End Sub



Note that &HFF0000 and 255 are the code of the colours taken from the forecolor in colour palette.

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

(B)        The same program using one timer only.(If we don’t know the first given colour)

     A)     Property :
       

   Timer : NAME-Timer1, INTERVAL-2000
   Textbox : NAME-Text1, TEXT-Hai


       

    B)   Attaching Code to the Object :
     
         
           Dim flag As Integer
          Private Sub Timer1_Timer()
       If flag = 1 Then
     Text1.ForeColor = &HFF&
    flag = 0
     Else
     Text1.ForeColor = &HC00000
      flag = 1
    End If
    End Sub

Note that &HFF&and &HC00000 are the code of the colours taken from the forecolor in colour palette.

  Back to Home   &  VB