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

Saturday, July 16, 2011

VB-2 : Speed Program



When we move the scroll bar the km/hour changes from 1 to 100, and “STOP” will close the operation.

A)   Property :
Textbox                    :   NAME – text1   , Text-(should kept blank)
Command Button 1  :  NAME -  Command1, CAPTION-Stop
Horizontal scroll bar :  min – 0, max-100

B)   Attaching Code to the Object :
Private Sub Command1_Click()
End
End Sub

Private Sub HScroll1_Change()
Text1.Text = Str(HScroll1.Value) + "km/hour"
End Sub
   Private Sub Text1_Change()
End Sub





Back to Home   &  VB


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

VB-45 : Calculate Electricity Bill

Design a VB application to calculate the Electricity Bill by taking the Consumer Name,Consumer No, Number of units by taking the details below into consideration.

  • 0 to 100 units      : Rs. 0.50 per unit
  • 101 to 200 units  : Rs. 0.85 per unit
  • 201 to 300 units  : Rs. 1.00 per unit
  • 301 and above    : Rs. 1.25 per unit


A)    Program Design : 

(B) Property(Controls Used) :
  1.  5 Labels with Captions as shown above
  2. 4 Text Boxes and given are their properties : 
  • The Text Property of text boxes for entering Consumer Number,units consumed and total amount should be kept as Zero and the text box for entering consumer name should be kept as blank
  • The Index Property of the four text boxes should be from 0 to 3 respectively
  • The Locked Property of the 4th text box (For calculating total amount) should be kept as True
    3.   One command button with caption Calculate Bill


(C) Attaching Code to the Object :
Private Sub Command1_Click()
Dim sum As Single
Dim unit As Integer

If Text1.Text = "" Or Text2.Text = "" Then
MsgBox "Enter Consumer Number and Name"
End If

unit = Round(Val(Text3.Text))

If unit > 300 Then
sum = (unit - 300) * 1.25
unit = 300
End If

If unit > 200 Then
sum = sum + (unit - 200) * 1
unit = 200
End If

If unit > 100 Then
sum = sum + (unit - 100) * 0.85
unit = 100
End If

sum = sum + unit * 0.5

Text4.Text = sum
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If (Index = 0 Or Index > 1) And (KeyAscii < 48 Or KeyAscii > 57) Then
SendKeys (Char(8))
End If
End Sub

Possible Error  : Sub or Function Not Defined

Refer Electricity Bill also.




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-44 : Reverse a given 5 digit number

Design a VB application to reverse the digits of a given 5 digit number.

Compare the same program I did in JAVA , the link is Reverse a number

Refer Reverse a String also.

A)    Program Design : 

(B) Property(Controls Used) :
  • 3 Labels with Captions  are Reverse Number,Enter any 5 digit number and Reverse Number is.
  • 2 Text Boxes ,Text property of both should be Zero, and the Locked Property of the second text box  (text2, to reverse the digits) must be true
  • One Command Button with Caption Reverse.

(C) Attaching Code to the Object :
Private Sub Command1_Click()
rev_no
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
SendKeys (Char(8))
End If
End Sub
Private Sub Text1_Change()
If Val(Text1.Text) > 99999 Then
SendKeys (Char(8))
End If
End Sub
Private Sub rev_no()
Dim rev As Integer
old = Val(Text1.Text)
While (Round(old) > 0)
rev = rev * 10 + old Mod 10
old = old / 10
Wend
End Sub





Possible Error  : Sub or function not defined

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