VERSION 5.00 Begin VB.Form Form1 Caption = "Percent Calculator" ClientHeight = 3975 ClientLeft = 60 ClientTop = 345 ClientWidth = 4605 Icon = "Form1.frx":0000 LinkTopic = "Form1" MaxButton = 0 'False ScaleHeight = 3975 ScaleWidth = 4605 StartUpPosition = 2 'CenterScreen Begin VB.CommandButton Command1 Caption = "&Go" Height = 405 Index = 1 Left = 555 TabIndex = 17 Top = 979 Width = 1455 End Begin VB.CommandButton Command1 Caption = "&Go" Height = 405 Index = 0 Left = 555 TabIndex = 16 Top = 2659 Width = 1455 End Begin VB.CommandButton Command1 Caption = "E&xit" Height = 405 Index = 2 Left = 1575 TabIndex = 13 Top = 3431 Width = 1455 End Begin VB.Frame Frame1 Caption = "Percent Calculator " Height = 1455 Index = 0 Left = 315 TabIndex = 7 Top = 139 Width = 3975 Begin VB.TextBox Text1 BackColor = &H8000000F& Height = 285 Index = 5 Left = 2600 Locked = -1 'True TabIndex = 15 Top = 900 Width = 975 End Begin VB.TextBox Text1 Height = 285 Index = 4 Left = 1845 MaxLength = 10 TabIndex = 11 Text = "40" Top = 330 Width = 735 End Begin VB.TextBox Text1 Height = 285 Index = 3 Left = 870 MaxLength = 10 TabIndex = 9 Text = "97" Top = 330 Width = 495 End Begin VB.Label Label1 AutoSize = -1 'True Caption = "Answer:" Height = 195 Index = 6 Left = 1920 TabIndex = 14 Top = 930 Width = 570 End Begin VB.Label Label1 AutoSize = -1 'True Caption = "?" Height = 195 Index = 5 Left = 2640 TabIndex = 12 Top = 360 Width = 90 End Begin VB.Label Label1 AutoSize = -1 'True Caption = "% of " Height = 195 Index = 4 Left = 1410 TabIndex = 10 Top = 360 Width = 390 End Begin VB.Label Label1 AutoSize = -1 'True Caption = "What is" Height = 195 Index = 3 Left = 240 TabIndex = 8 Top = 360 Width = 540 End End Begin VB.Frame Frame1 Caption = " Reverse Percent Calculator " Height = 1455 Index = 1 Left = 315 TabIndex = 0 Top = 1819 Width = 3975 Begin VB.TextBox Text1 BackColor = &H8000000F& Height = 285 Index = 2 Left = 2600 Locked = -1 'True TabIndex = 6 Top = 900 Width = 975 End Begin VB.TextBox Text1 Height = 285 Index = 1 Left = 2600 MaxLength = 10 TabIndex = 4 Text = "45" Top = 360 Width = 975 End Begin VB.TextBox Text1 Height = 285 Index = 0 Left = 240 MaxLength = 10 TabIndex = 1 Text = "35" Top = 360 Width = 855 End Begin VB.Label Label1 AutoSize = -1 'True Caption = "Answer: " Height = 195 Index = 2 Left = 1920 TabIndex = 5 Top = 930 Width = 615 End Begin VB.Label Label1 AutoSize = -1 'True Caption = "?" Height = 195 Index = 1 Left = 3670 TabIndex = 3 Top = 390 Width = 90 End Begin VB.Label Label1 AutoSize = -1 'True Caption = "is what percent of" Height = 195 Index = 0 Left = 1200 TabIndex = 2 Top = 390 Width = 1260 End End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Sub Command1_Click(Index As Integer) Select Case Index Case 0 'reverse percent calculator Dim tmpString If Val(Text1(1).Text) = 0 Then 'can't divide by 0 Text1(2).Text = "0.00" Else tmpString = FormatPercent((Val(Text1(0).Text) / Val(Text1(1).Text)), 2, vbUseDefault, vbFalse, vbTrue) If Mid(tmpString, Len(tmpString) - 3) = ".00%" Then Text1(2).Text = Mid(tmpString, 1, Len(tmpString) - 4) & "%" Else Text1(2).Text = tmpString End If End If Case 1 'percent calculator Dim tmpString2 tmpString2 = FormatNumber((Val(Text1(3).Text) / 100) * Val(Text1(4).Text), 2, vbTrue, vbFalse, vbTrue) If Mid(tmpString2, Len(tmpString2) - 2) = ".00" Then Text1(5).Text = Mid(tmpString2, 1, Len(tmpString2) - 3) Else Text1(5).Text = tmpString2 End If Case 2 'exit button Unload Me End Select End Sub Private Sub Text1_GotFocus(Index As Integer) Text1(Index).SelStart = 0 Text1(Index).SelLength = Len(Text1(Index).Text) Text1(Index).SetFocus End Sub