Results 1 to 13 of 13

Thread: Visual Basic Program Help .. Really stuck

Threaded View

  1. #3

    Thread Starter
    New Member
    Join Date
    May 2009
    Posts
    6

    Re: Visual Basic Program Help .. Really stuck

    Hi Hack
    Thanks for your reply, hmm yes i understand that.

    Basically i have created the layout of the program.

    I have experimented with some codes. but not much luck

    Code:
    Option Explicit
    Dim FirstNumber As Integer
    Dim SecondNumber As Integer
    Dim ThirdNumber As Integer
    Dim Total As Integer
    
    Private Sub Command1_Click()
    ElseIf (Add = False) And _
    (Minus = False) And _
    (Divide = False) And _
    (Mulitiply = False) Then
    MsgBox "Please choose an Option"
    
    ElseIf (OptAdd) Then
    
    End If
    
    
    If Add = True Then
    
    lblResult = Val(text01.Text) + Val(text02.Text)
    
    ElseIf Minus = True Then
    
    lblResult = Val(text01.Text) - Val(text02.Text)
    
    ElseIf Multiply = True Then
    
    lblResult = Val(text01.Text) * Val(text02.Text)
    
    ElseIf Divide = True Then
    
    lblResult = Val(text01.Text) / Val(text02.Text)
    
    End If
    End Sub
    
    Private Sub Command2_Click()
    
    End Sub
    
    Private Sub cmdAbout_Click()
    MsgBox ("Program: Interior Decorating Estimation Calculator 1.0, Author: 277302, ID Code: 277302")
    End Sub
    
    Private Sub cmdEnter_Click()
        Dim Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec As String
        Dim strNumber As String
        Dim blnNumberValid As Boolean
            
        Jan = "January"
            Feb = "February"
                Mar = "March"
                    Apr = "April"
                         May = "May"
                            Jun = "June"
                                Jul = "July"
                                    Aug = "August"
                                        Sep = "September"
                                            Oct = "October"
                                                Nov = "November"
                                                    Dec = "December"
        
      blnNumberValid = False
        
       
        Do
            strNumber = InputBox("Please type a number between 2 and 6", "Data Entry")
        
                If strNumber = "" Or Not IsNumeric(strNumber) Then
                    MsgBox "[WARNING - Invalid Number] Please enter a number between 2-6"
                    
                    ElseIf CInt(strNumber) < 1 Or CInt(strNumber) > 6 Then
                        MsgBox "[WARNING - Number exceeds 6] Please enter a number between 2-6"
                    Else
                       blnNumberValid = True
                End If
                
        Loop Until blnNumberValid = True
         
    
    
        If strNumber = "1" Then
            Text2.Text = " 31"
                Text1.Text = (Jan)
            End If
        If strNumber = "2" Then
        
        If Year(Date) Mod 400 = 0 Then
            
            Text2.Text = "29"
                Text1.Text = (Feb)
                
                ElseIf Year(Date) Mod 100 = 0 Then
                    Text2.Text = "28"
                        Text1.Text = (Feb)
                ElseIf Year(Date) Mod 4 = 0 Then
                    Text2.Text = "29"
                        Text1.Text = (Feb)
                Else: Text2.Text = "28"
                    Text1.Text = (Feb)
        End If
        
        End If
        
        If strNumber = "3" Then
            
            Text2.Text = " 31"
            Text1.Text = (Mar)
            
            ElseIf strNumber = "4" Then
                Text2.Text = " 30"
                    Text1.Text = (Apr)
            ElseIf strNumber = "5" Then
                Text2.Text = " 31"
                        Text1.Text = (May)
            ElseIf strNumber = "6" Then
                Text2.Text = " 30"
                            Text1.Text = (Jun)
            Else
                
                blnNumberValid = True
        
        
        
        
        
        
        
        
        
        If IsNumeric(Text1.Text) = False Or _
    IsNumeric(Text2.Text) = False Then
    MsgBox "Incorrect Value: Please enter the correct value"
    
    ElseIf (Text2.Text) = "0" And (OptDivide) Then
    MsgBox "It is not possible to divide by zero"
    
    ElseIf (Add = False) And _
    (Minus = False) And _
    (Divide = False) And _
    (Mulitiply = False) Then
    MsgBox "Please choose an Option"
    
    ElseIf (OptAdd) Then
    
    End If
    
    
    If Add = True Then
    
    lblResult = Val(Text1.Text) + Val(Text2.Text)
    
    ElseIf Minus = True Then
    
    lblResult = Val(Text1.Text) - Val(Text2.Text)
    
    ElseIf Multiply = True Then
    
    lblResult = Val(Text1.Text) * Val(Text2.Text)
    
    ElseIf Divide = True Then
    
    lblResult = Val(Text1.Text) / Val(Text2.Text)
    
    End If
    
        
        
        
        
        End If
    
    End Sub
    
    Private Sub cmdExit_Click()
    Unload Me
    End Sub
    
    Private Sub Label3_Click()
    
    End Sub
    
    Private Sub Form_Load()
    Form1.Show
    FirstNumber = InputBox("Enter the height of the room (Between 2-6)")
    SecondNumber = InputBox("Enter the length of all 4 walls (Between 1-25)")
    Total = FirstNumber + SecondNumber
    Print "The total is", Total
    End Sub
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width