Announcement

Collapse
No announcement yet.

Get Each Letter From String

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get Each Letter From String

    HIi again for everybody. As you can know I'm a new user for VBA. I learn to program in C. Somethings for VBA are easy somethings no.

    But there is my question:

    Can I use a string in VBA just like C.
    I'm trying to get character one by one for a string.
    Can I do somehting like that here?

    In C I use:
    char string[20];
    For ( int i = 0; string[i] != '\0"; i++)
    cout << string[i];
    Last edited by Jack in the UK; October 28th, 2006, 18:34.

  • #2
    Re: Use Strings Like C

    Ed_Kerrigan,

    You may get more help if you try to say in words what you want to accomplish without the C code (I can't read C).

    Jim

    Comment


    • #3
      Re: Use Strings Like C

      Ed, as you problem is getting each letter from a String, why not use something like that for your Thread Title?

      POOR THREAD TITLE Please read THIS PAGE IN FULL

      Code:
      Sub GetLetters()
      Dim strArray() As String
      Dim strText As String
      Dim lLoop As Long, lCount As Long
      
          strText = "Hello"
          lCount = Len(strText)
          ReDim strArray(lCount - 1)
      
              For lLoop = 0 To lCount - 1
                  strArray(lLoop) = Mid(strText, lLoop + 1, 1)
              Next lLoop
      
          Range("A1:A" & lCount) = WorksheetFunction.Transpose(strArray)
      End Sub

      Comment


      • #4
        Re: Use Strings Like C

        Thaks Dave to remember me the rules.
        I'll try to follow it.
        Thank to for the answer

        Comment

        Working...
        X