How to analyse a string of characters in VBA

Hi,
I need to know if a list of character contains only letters or if it contains a numeric part, or only numeric.
How can I do that ?
Thanks

WLID1966,
At first I thought it could be done with a formula in a custom field, and it probably could, but the formula would be unwieldy. Therefore I developed this little macro to do the job.
Sub chkStrforNumLet()
Dim t As Task
Dim str As String
Dim Num As Boolean, Ltr As Boolean
For Each t In ActiveProject.Tasks
    If Not t Is Nothing Then
        str = t.Name
        Num = False: Ltr = False
        For i = 1 To Len(t.Name)
            If Asc(str) > 47 And Asc(str) < 58 Then Num = True
            If Asc(str) > 64 And Asc(str) < 91 Or _
                 Asc(str) > 96 And Asc(str) < 123 Then Ltr = True
            If Num = True And Ltr = True Then Exit For
            str = Mid(str, 2)
        Next i
        If Num = True And Ltr = True Then t.Text1 = "Mixed"
        If Num = True And Ltr = False Then t.Text1 = "Numbers"
        If Num = False And Ltr = True Then t.Text1 = "Letters"
    End If
Next t
End Sub
If this answers your question, please mark it as the answer.
John

Similar Messages

  • Help!How to analyse a String?

    I got text in Strings and i want to know if each word are a "date", a "int", "currency",etc...
    So i want to know if Java gots methods to determine the type of each words of my strings.
    In another words, i just want to know if i can do something like:
    String str = "1234";
    boolean bool = str.isInt();
    Any help would be greatly appreciated.
    Best Regards
    A.Santos

    Hi! Here's how you can implement some methods of your own. The following methods checks if the given string represents an integer.
    boolean isInteger( String s )
       int i;
       boolean fReturn = true;
       try
          i = Integer.parseInt( s );
       catch( NumberFormatException x )
          fReturn = false;
       return fReturn;
    }For doubles and floats, use the Double.parseDouble() and Float.parseFloat() methods.
    To check if a string represents a date, look at Q.120 in the Question of the Week archives. I've illustrated how to use the java.text.SimpleDateFormat class to convert from the string format to a date format. In this case, you'll have to check for ParseException if the string does not represent a date.
    Hope this helps! If something's not very clear, feel free to ask.
    Cheers!

  • How to extract an integer or a float value from a String of characters

    Hi i have a problem getting to a float value within a string of characters..
    for instance the string is
    "numberItem xxxxxxxxx 700.0" (each x is a space..the forum wouldnt let me put normal spaces for some reason)
    how do i store 700.0 in a float variable
    remember the string is obtained from an inputfile
    so far i got the program to store the inputfile data line by line in a String array..i tried tokenizing the string to get to the the float value but since i have mulitple spaces within my string, the token method only gets "numberItem" from the above String
    This is all i have so far:
    String c;
    String Array[] =new String[g]; (i used a while loop to obtain g(the nubmer of lines in the file))
    while((c=(cr.readLine()))!=null)
    Array[coun]=c;
    it would be reallllllllllllllllllllllllllllllllllllllly easy if there was a predefined method to extract numeric values from a string in java..
    Edited by: badmash on Feb 18, 2009 5:50 PM
    Edited by: badmash on Feb 18, 2009 5:50 PM
    Edited by: badmash on Feb 18, 2009 5:55 PM

    badmash wrote:
    Hi i have a problem getting to a float value within a string of characters..
    for instance the string is
    "numberItem xxxxxxxxx 700.0" (each x is a space..the forum wouldnt let me put normal spaces for some reason)
    with the space included
    how do i store 700.0 in a float variable
    remember the string is obtained from an inputfile
    so far i got the program to store the inputfile data line by line in a String array..i tried tokenizing the string to get to the the float value but since i have mulitple spaces within my string, the token method only gets "numberItem" from the above StringHuh?
    Not true.
    Anyway why not use string split, split on spaces and grab the last element (which by the format you posted would be your 700.0)
    Then there is the Float.parseFloat method.
    It is easy.
    And another thing why not use a List of Strings if you want to store each line? (And why did you post that code which doesn't really have anything to do with your problem?) Also in future please use the code formatting tags when posting code. Select the code you are posting in the message box and click the CODE button.

  • How to compare two strings whether both are equal while ignoring the difference in special characters (example: & vs & and many others)?

    I attempted to compare two strings whether they are equal or not. They should return true if both are equal.
    One string is based on Taxonomy's Term (i.e. Term.Name) whereas other string is based on String object.
    The problem is that both strings which seem equal return false instead of true. Both string values have different special characters though their special characters are & and &
    Snapshot of different design & same symbols:
    Is it due to different culture or language?
    How to compare two strings whether both are equal while ignoring the difference in special characters (& vs &)?

    Hi Jerioon,
    If you have a list of possible ambiguous characters the job is going to be easy and if (& vs &) are the only charracters in concern awesome.
    You can use the below solution.
    Before comparing pass the variables through a replace function to standarize the char set.
    $Var = Replace($Var,"&","&")
    This is going to make sure you don't end up with ambiguous characters failing the comparison and all the char are "&" in this case.
    Similar technique is used to ignore Character Cases 'a' vs. 'A'
    Regards,
    Satyajit
    Please “Vote As Helpful”
    if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

  • How to find no of numeric characters in a given string ???

    How to find no of numeric characters in a given string ???
    Thanks,
    Kathir

    sabre150 wrote:
    Use String.replaceAll() to replace any characters that are not numeric and then take the length of the resultant String....and this might be useful: [http://www.regular-expressions.info/]
    ;-)

  • My new wirelss keyboard is repeating the "\" character endlessly; also inserting them into the string of characters I'm typing.  It does is in word and in both safari and firefox.  How do I get this to stop?

    My new wireless keyboard is repeating the "\" character endlessly.  It also inserts the '\" into strings of characters as I type them in word or safari or firefox.  I can't erase the characters fast enough or type fast enough not to get these characters.  \Help!

    Try changing the batteries on the keyboard or see if the keyboard has some sort of reset available.

  • How to send non-latin unicode characters from Flex application to a web service?

    Hi,
    I am creating an XML containing data entered by user into a TextInput. The XML is sent then to HTTPService.
    I've tried this
    var xml : XML = <title>{_title}</title>;
    and this
    var xml : XML = new XML("<title>" + _title + "</title>");
    _title variable is filled with string taken from TextInput.
    When user enters non-latin characters (e.g. russian) the web service responds that XML contains characters that are not UTF-8.
    I run a sniffer and found that non-printable characters are sent to the web service like
    <title>����</title>
    How can I encode non-latin characters to UTF-8?
    I have an idea to use ByteArray and pair of functions readMultiByte / writeMultiByte (to write in current character set and read UTF-8) but I need to determine the current character set Flex (or TextInput) is using.
    Can anyone help convert the characters?
    Thanks in advance,
    best regards,
    Sergey.

    Found tha answer myself: set System.useCodePage to false

  • How to pass a string varaible to an internal table field

    Hi Experts,
    I am reading notes/text entries by calling read_text and then passing them in a variable. I want to display the notes. But even after declaring the variable as  LINE2048, it is displaying only 255characters as output length.
    My code:
    TYPES: BEGIN OF TYP_FINAL,
             PARTNER_NO      TYPE BU_PARTNER,         "Partner No.
            OBJECT_ID       TYPE CRMT_OBJECT_ID_DB,  "Object ID
            PROCESS_TYPE    TYPE CRMT_PROCESS_TYPE,  "Activity Type
           ACTUAL_NOTE     TYPE LINE2048,           "Actual Notes
           END OF TYP_FINAL.
    data : T_FINAL           TYPE STANDARD TABLE OF TYP_FINAL,
              WA_FINAL          TYPE TYP_FINAL.
    data:  v_actualnote     TYPE LINE2048.
              CALL FUNCTION 'READ_TEXT'
                EXPORTING
                 CLIENT                        = SY-MANDT
                  ID                            = C_0002
                  LANGUAGE                      = sy-langu
                  NAME                          = l_name1
                  OBJECT                        = C_BUT000
                TABLES
                  LINES                         = t_line
               EXCEPTIONS
                 ID                            = 1
                 LANGUAGE                      = 2
              IF SY-SUBRC = 0.
               clear: v_accountnote.
               LOOP AT T_LINE INTO WA_LINE.
                 CONCATENATE v_accountnote wa_line INTO v_accountnote SEPARATED BY space.
                 clear: wa_line.
               ENDLOOP.
              wa_final-account_note = v_accountnote.
              clear: v_accountnote.
             ENDIF.
    So, if I make the v_actualnote as string and pass it to a string variable, that should work.
    But the system is not allowing me to declare a string varaible inside the internal table.
    Please let me know how to display more than 255 characters in v_accountnote  .
    Regards,
    Sangeeta.

    you are passng that as a string = '5,6' does not exist
    try this : http://www.mssqltips.com/sqlservertip/1771/splitting-delimited-strings-using-xml-in-sql-server/
    declare @table table(sno int)
    insert into @table values(5),(6)
    DECLARE @xml as xml,@txtSchedule as varchar(100),@delimiter as varchar(10)
    SET @txtSchedule='5,6'
    SET @xml = cast(('<X>'+replace(@txtSchedule,',','</X><X>')+'</X>') as xml)
    select * from @table WHERE sno IN ( select N.value('.', 'varchar(10)') as value FROM @xml.nodes('X') as T(N))
    Hope it Helps!!

  • Have Firefox & Bing and when I open Firefox I get Ref A and string of characters; then when I get to Bing, no toolbar with bookmarks, etc or way to access mail.

    I made Bing my browser and it was working fine until today. When I open Firefox I get a message Ref A: and then a long string of characters. I click on the home icon and the string changes. After doing this several times I get the Bing search page. I do not get the Firefox start page with the tool bar that has my book marks, history etc. I cannot clear the cache if I cannot not get the history tab. If I go the the mozilla firefox program folder and open it, there is a tool bar but cannot clear recent history, etc. there. I do not have an administrator & password on my home desk top; it is just me. I tried to follow your suggestions, but they do not apply to my situation. I really don't know if this is a firefox or bing problem. I used google before bing and had no problems; just wanted to try bing.

    Can you attach a screenshot?
    *http://en.wikipedia.org/wiki/Screenshot
    *https://support.mozilla.org/kb/how-do-i-create-screenshot-my-problem
    Use a compressed image type like PNG or JPG to save the screenshot.
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • How to create a String with a specific size?

    how to create a String with a specific size?
    For example I want to create different Strings with the size of 100 , 1000 or 63k byte?

    String are immutable so just initialize it with the number of characters you want.
    You might want to look at java.lang.StringBuffer and see if that's what you want.

  • How to search a string from the database?

    how to search a string from the database? starting with some character

    If you're trying to do this in a SELECT, you can use the LIKE verb in your WHERE clause.
    Here's an Example
      SELECT obj_name FROM tadir
        INTO prog
        WHERE pgmid = 'R3TR'
          AND object = 'PROG'
          AND obj_name LIKE 'Z%'.
    In this case it will select every row that obj_name starts with Z. 
    If you wanted to find every row that the field obj_name contains say... 'WIN'  you use LIKE '%WIN%'.
    Edited by: Paul Chapman on Apr 22, 2008 12:32 PM

  • Delete spaces on the right of a string of characters

    Hi,
    I'd like to know how to delete space on the right of a string of characters and ONLY the ones on the right in order I can get the real length of the string (I don't want to condense the spaces between words even though there's more than one).
    data: text(20).
    text = 'SAP Forum'
    In this case, if I use both DESCRIBE LENGTH and DESCRIBE OUTPUT LENGTH, the result will be 20, but the real length is 9.

    Use STRLEN( ), as described by the other posters.
    To delete space chars on the right of a string, use following static method:
    CALL METHOD cl_abap_string_utilities=>del_trailing_blanks
      CHANGING
         str = lv_text.

  • How to convert EBCDIC String in hex to unicode?

    How do I convert, for example, "C1C2C3C4C5" (EBCDIC in hex) to "ABCDE"? The input and output types are both String. Thanks in advance!

    1. Create a String of 256 characters, where the index corresponds to the ASCII character (e.g. character at index 193 (0xC1) would be 'A').
    2. Parse your input string two characters at a time using Integer.parseInt(s, 16) to convert the two digits to a number, and use the resulting number to get the equivalent ASCII character from the translation string in step 1, which can be appended to your output.

  • CONCATENATE a string a characters into a field

    Hi everyone!
    Let's say that i want to CONCATENATE a string of characters (for example: 'ABC') into every WTAB-AUFNR record that i retrieve. How do i do that?
    Let's assume that WTAB-AUFNR's header currently has the value '50-12345', i want it to be 'ABC50-12345'.

    I've got another CONCATENATE question. Here it is:
    Let's say i wanna have the values in CTAB-WTJHR to be in brackets, which i am going to hardcode by doing a CONCATENATE. So it should work if i write it like this:
    DATA: BEGIN OF CTAB OCCURS 0,
          LEDNR LIKE BPJA-LEDNR,  "Ledger
          OBJNR LIKE BPJA-OBJNR,  "Object Number
          TRGKZ LIKE BPJA-TRGKZ,  "Object Indicator
          WRTTP LIKE BPJA-WRTTP,  "Value Type
          GJAHR LIKE BPJA-GJAHR,  "Fiscal Year
          VERSN LIKE BPJA-VERSN,  "Version
          VORGA LIKE BPJA-VORGA,  "Budget Type
          TWAER LIKE BPJA-TWAER,  "Transaction Currency
          WTJHV LIKE BPJA-WTJHV,  "Original Budget
          WTJHR LIKE BPJA-WTJHR,  "Amount Utilised YTD
          V_BEFORE TYPE I,             "Balance Before This Request
          V_CURRENT TYPE I,            "Current Acquisition Cost
          V_BALANCE TYPE I,            "Balance Variation
          END OF CTAB.
    SELECT SINGLE LEDNR OBJNR TRGKZ WRTTP GJAHR VERSN VORGA TWAER WTJHV
    WTJHR
      INTO CTAB
      FROM BPJA
      WHERE OBJNR = WTAB-AUFNR AND
            WRTTP = '42' AND
            GJAHR = ITAB-LFDAT+0(4).
    APPEND CTAB.
    LOOP AT CTAB.
    CONCATENATE '(' CTAB-WTJHR ')' INTO CTAB-WTJHR.
      MODIFY CTAB TRANSPORTING WTJHR.
    ENDLOOP.
    I've looked through it and i can't find any syntax problem or anything else but i keep getting this message when i try to activate my program: "CTAB-WTJHR" must be a character-type data object (data type C, N, D, T or STRING). field string". When i looked at SE11 and i found out that the WTJHR field in BPJA is a type CURR. Is there a way to solve this?

  • Changing strings to characters

    I have been trying to program this and its not working. I am a java student, so my level of java understanding is pretty basic. well REALLY basic considering the depth and scope of the java language. plus I have only been at this about 2 months. so please keep it as simple as you can. thanks!
    This is the question:
    Write a program for a furniture company. Ask the suer to choose P for pine, O for oak, or M for mahogany. Show the price of a table manufacture with the chosen wood. Pine tables cost $100, oak costs $224, and mahogany costs $310.
    Add a prompt to the program to ask the user to specify a large (L) or small (S) table. ass $35 to the price of any large table.
    and this is what I have so far:
    import java.io.*;     
    public class Furniture
         public static void main(String[]args) throws IOException
              BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
              String swood;
              int mahogany = 310;
              int pine = 100;
              int oak = 225;
              int total = 0;
              String size = "";
              System.out.println("Enter wood: ");
              swood = dataIn.readLine();
              System.out.println("Small or Large?");
              size = dataIn.readLine();
              if(swood == "P")
                   total = 100;
                   System.out.println("Total is: " + total);
              else if(swood == "O")          
                   total = 225;
                   System.out.println("Total is: " + total);
              else if(swood == "M")
                   total = 310;
                   System.out.println("Total is: " + total);
              if(size == "L")
                   int newtotal = total + 35;
                   System.out.println("The new total is: " + newtotal);
    I need to convert my strings into characters but i am not able to figure out how to do it...we have done other conversions using Integer.parseInt() and similar methods but Character.parseChar() is apparently not a part of the java.io package.
    If there are any other changes that need to be made plz point them out. thanks.
    also i tried using Char.At() but i couldnt get it to work??
    Edited by: desichick07 on Oct 25, 2007 4:42 PM

    They meant like this:
    Your current code for the condition was like this:
    if(swood == "P")
    total = 100;
    System.out.println("Total is: " + total);
    else if(swood == "O")
    total = 225;
    System.out.println("Total is: " + total);
    else if(swood == "M")
    total = 310;
    System.out.println("Total is: " + total);
    if(size == "L")
    int newtotal = total + 35;
    System.out.println("The new total is: " + newtotal);
    Now change your code to something like this:
    if(swood.equals("P"))
    total = 100;
    System.out.println("Total is: " + total);
    else if(swood.equals("O"))
    total = 225;
    System.out.println("Total is: " + total);
    else if(swood.equals("M"))
    total = 310;
    System.out.println("Total is: " + total);
    if(size.equals("L"))
    int newtotal = total + 35;
    System.out.println("The new total is: " + newtotal);
    }so instead of using "==", you replace it with equals().

Maybe you are looking for

  • Why does my iPad (3rd Gen.) keep turning itself on and off?

    I currently have my 3rd generation iPad plugged into the wall charger. It has been plugged in since yesterday morning and is still going through the same routine: on, off, on, off...HELP! I have tried to reset it, but it won't respond; the screen jus

  • Is there a Digital Version of the TRM manuals for 10.7 ?

    I currently have access to a set of TRM manuals for a 10.7 installation. I may be relocating and will continue to support this install from another location and will not be able to take the TRM books with me. Does anyone know of an electronic version

  • What happened to quicktime Pro on my Macbook (ie. it is now useless)

    Hi, So upon completing a very simple imovie project (30s, 5 clips), I tried to 'share' it and save it as a decent sized quicktime file. There are no video options avaliable under the expert settings....just audio setings! And, this happens no matter

  • Problem extracting variables passed through a url

    Hi I'm trying to pass two variables via a url which I can acheive, but I'm having trouble extracting the information when page refreshes. This is the code I've used to pass the variables:_ <?php while ($row = mysql_fetch_assoc($result1)) {   ?> <a hr

  • Synchronous operation with a message selector possible?

    I have a situation where the following condition exists: - a number of servlet threads (1-n) will post to request to an external asynchronous system with a unique id. - the external system will post the responses to a JMS queue. - my servlet threads