get rid of a-z and A-Z

Discussion in 'Programming General' started by dbmain, Nov 28, 2007.

get rid of a-z and A-Z
  1. Unread #1 - Nov 28, 2007 at 9:12 PM
  2. dbmain
    Referrals:
    0

    dbmain Guest

    get rid of a-z and A-Z

    i am trying to do a little program where it gives you a request like 554884225 and you have to ask me for the code and the code is just that number divided like by 5 and it works perfectly but... if there is even a single letter i get an error. i need find out how to get rig of any text like a,b,c,d,e,f,g,h,i,j,k,l,m,etc i know i could do replace but that would take up allot of space i am trying to keep this short.
     
  3. Unread #2 - Nov 29, 2007 at 1:24 AM
  4. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    get rid of a-z and A-Z

    Here's what I wrote for ya. Send the string you want letters removed from to the function and it returns the number as a double variable so you won't get overflow errors caused by bigger numbers. Hope it's helpful.:)
    Code:
    Public Function StripLetters(Number As String) As Double
    i = 0
    While i < Len(Number)
    i = i + 1
    If Not (IsNumeric(Mid(Number, i, 1))) Then
    Number = Mid(Number, 1, i - 1) + Mid(Number, i + 1)
    i = i - 1
    End If
    Wend
    StripLetters = Number
    End Function
    
    You can call it with something like either of these.
    Code:
    MsgBox (StripLetters(Text1.Text))
    
    MsgBox (StripLetters("2432uahuaaA32Y2112I2RJ2IJI121S"))
    
     
  5. Unread #3 - Nov 29, 2007 at 5:13 AM
  6. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    get rid of a-z and A-Z

    Code:
    Private Function Shizzle(ByVal strText As String) As Long
        Dim i As Long, strChar As String
        For i = 1 To Len(strText)
            strChar = Mid(strText, i, 1)
            Shizzle = Shizzle & IIf(UCase(strChar) Like "[A-Z]", "", strChar)
        Next i
    End Function
     
< [TUT] Starting a Word Processor | Can someone make me a simple bot to.. >

Users viewing this thread
1 guest


 
 
Adblock breaks this site