Results 1 to 8 of 8

Thread: LenB Function

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    299

    Thumbs up

    How do you get the LenB of an array? How do you call it??

    Any ideas?
    BW

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Well usually you use LenB with UDT's, so i guess you could use it like this
    Code:
    Private Type sArray
       s(10)  As String
    End Type
    
    Private Sub Form_Load()
    Dim a As sArray
        MsgBox LenB(a)
    End Sub
    It will show a empty variable length string array of 10 items will take up 44 bytes
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    299

    Will that work?

    I need to redimension the array within a sub, will that still work if its in a UDT?
    BW

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You would need to redefine it then...
    Code:
    Private Type sArray
       s()  As String
    End Type
    
    Private Sub Form_Load()
    Dim a As sArray
        redim a.s(30)
        MsgBox LenB(a)
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2000
    Posts
    299

    Cool Cool, thought so

    I thought that might be it, hadn't tried it just yet. Good to hear its possible though.

    BW

    BTW is your website fully functional? Went to take a look, and it took a while (only got to the Kedaman.com site, not the Geocities site).

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Yeah, geocities is a bit crappy today, well you can have a direct link here:
    http://www.geocities.com/kedasu/homepage.htm
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Unless you're using Variants or strings then you can just multiply the LenB of the first element by the number of elements, If it's a String use LenB(Join(Arr(),""))



    Here's a quick Demo

    Code:
    Private Sub Command1_Click()
    Dim s(5 To 8) As String
    Dim l(-4 To 9) As Long
    
    Dim i As Integer
    
    For i = 5 To 8
        
        s(i) = "Hello" & Space(i)
        
    Next i
    
    For i = -4 To 9
    
        l(i) = i
        
    Next i
    
    
    MsgBox LenB(Join(s, ""))
    
    MsgBox LenB(l(LBound(l))) * (UBound(l) - LBound(l))
    
    End Sub

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Well done again Sam!
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

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



Click Here to Expand Forum to Full Width