Results 1 to 5 of 5

CInt() conversion & inputbox

Threaded View

  1. #1
    Registered User
    Join Date
    06-26-2009
    Location
    O.o
    MS-Off Ver
    Excel 2003
    Posts
    64

    CInt() conversion & inputbox

    Hi everybody, as i understand CInt() converts STRING variables to INTEGER variables.

    I am trying to create an inputbox, with input validation. So, if the user types in an integer, it will continue to a msgbox; if they type a number in string format, as in 'two', it will convert this into an integer and again display it in a msgbox; if they press nothing a msgbox will appear telling them there is no input; and if they press cancel the programme closes. Any help would be appreciated.



    Sub x()
    
    Dim heads As String, tails As Integer
    
    If heads = InputBox("enter a number", , _
                                    vbOKCancel) = vbCancel Then
          Application.Close
    ElseIf IsNumeric(heads) Then
          CInt(heads)=  tails
    Else
         Msgbox "No number, stupid"
         Exit Sub
    End If
    
    Msgbox heads & " " & tails
    
    End Sub
    Last edited by dems; 07-06-2009 at 01:44 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