VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This is an example of a string manipulation program. This simple program demonstrates how to calcul

by Junel Corales (2 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 15th August 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This is an example of a string manipulation program. This simple program demonstrates how to calculate the number of hours between two times

Rate This is an example of a string manipulation program. This simple program demonstrates how to calcul



'Note: this sample program is my own work and please don't take credit for it.
'if you have any comments or suggestions just e-mail me to
'[email protected]
'This is an example of string manipulation program.
'this simple program demonstrates how to calculate the no. of hours between two time entered


'Coding
Option Explicit

Private Sub cmdCalculate_Click()
    Dim time1, string10 As Integer
    Dim string1, string2, string3, string4, string5, string6, string7, string8, string9, string11, string12, string13, string14, string15 As String
    Dim salary, salary2 As Single
      
    string1 = Text1.Text
    string2 = Text2.Text
    
    'removes the colon character and combines the hour and minute
    string3 = Left(string1, 2)
    string4 = Right(string1, 2)
    string5 = string3 & string4
    
    string6 = Left(string2, 2)
    string7 = Right(string2, 2)
    string8 = string6 & string7
    
    
    'calculates no of hours worked
    string9 = Val(string8) - Val(string5)
    string10 = Len(string9)
    Text3.Text = string10
    'Inserts colon character between the hour and minute
    If string10 = 3 Then
        string11 = Left(string9, 1)
        string12 = Right(string9, 2)
        string13 = string11 & ":" & string12
        Text3.Text = string13
    Else
        If string10 = 4 Then
        string11 = Left(string9, 2)
        string12 = Right(string9, 2)
        string13 = string11 & ":" & string12
        Text3.Text = string13
    End If
    End If
        
    If Val(string11) > 8 Then
        string14 = Val(string11) - 8
        string15 = string14 * 62.5
        salary2 = Val(string15) + 400
        Text4.Text = "P" & Str(salary2)
    Else
        'the rate I used is 50 per hour, you can change it if you like
        'I used Philippine Peso as the currency
        salary = 50 * Val(string11)
        Text4.Text = "P" & Str(salary)
    End If
End Sub

Private Sub Form_Load()
    Top = (Screen.Height - Me.Height) \ 2
    Left = (Screen.Width - Me.Width) \ 2
End Sub


Download this snippet    Add to My Saved Code

This is an example of a string manipulation program. This simple program demonstrates how to calcul Comments

No comments have been posted about This is an example of a string manipulation program. This simple program demonstrates how to calcul. Why not be the first to post a comment about This is an example of a string manipulation program. This simple program demonstrates how to calcul.

Post your comment

Subject:
Message:
0/1000 characters