Results 1 to 7 of 7

VBA If else statement

Threaded View

peedarp1985 VBA If else statement 05-11-2010, 02:22 PM
royUK Re: VBA programming help 05-11-2010, 02:22 PM
foxguy Re: VBA If else statement 05-11-2010, 06:44 PM
peedarp1985 Re: VBA If else statement 05-11-2010, 11:33 PM
foxguy Re: VBA If else statement 05-14-2010, 05:58 PM
Leith Ross Re: VBA If else statement 05-14-2010, 09:28 PM
peedarp1985 Re: VBA If else statement 05-14-2010, 11:52 PM
  1. #1
    Registered User
    Join Date
    05-11-2010
    Location
    Portland oregon
    MS-Off Ver
    Excel 2007
    Posts
    10

    VBA If else statement

    Hi,
    I am trying to write a program for a user form which takes data from the user interface and calculates on the command click and I am trying to do using if else statements but something is wrong can any body help me with this. The code have written is below. I am a beginner and just started using VBA.

    Thanks

    Private Sub Tolerance_Click()
    
    Dim Msg1 As String
    Msg1 = Msg1 & ComboBox1
    Dim D As Integer
    D = D & TextBox1
    Dim L As Integer
    L = L & TextBox2
    Dim Ts As Integer
    Dim S As Integer
    Dim Ci As Integer
    Dim Cy As Integer
    
    If Msg1 = "Size" Then
    Select Case D
    Case Is >= 0.25
    Ts = 0.001 + (0.006 + 0.005 * D)
    Case Is < 0.25
    Ts = 0.001 + (0.003 + 0.016 * D)
    MsgBox Ts
    End Select
    
    
    If Msg1 = "Straightness" Then
    S = L * 0.0087
    MsgBox S
    
    
    If Msg1 = "Circularity" Then
    Ci = 0.25 * Size
    MsgBox Ci
    
    
    If Msg1 = "Cylindricity" Then
    Cy = S + Ci
    MsgBox Cy
    
    End If
    
    End Sub
    Last edited by peedarp1985; 05-14-2010 at 11:52 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1