A basic question: Len ( )

Results 1 to 3 of 3

Thread: A basic question: Len ( )

  1. #1
    Join Date
    Dec 1969

    Default A basic question: Len ( )

    Being a seasoned programmer I feel silly asking this, even if I am just starting out in .NET but it has stumped me to no end :-/<BR><BR>When using Len( ) function in my asp.NET pages, I get the error message:<BR>&#060;code&#062;<BR>Compiler Error Message: BC30451: Name &#039;Len&#039; is not declared.<BR>&#060;/code&#062;<BR><BR>I&#039;m assuming I am missing an Imports statement, but I can not find any documentation stating what it might be. <BR><BR>Thanks!<BR>Chris.

  2. #2
    Join Date
    Dec 1969

    Default Not to ask a silly question...

    ...but this *is* VB.NET, yes? Not C#.NET?<BR><BR>Because in VB.NET, this code worked perfectly for me (and even gave me the right intellisense):<BR><BR> Private Sub foo(ByVal bar As String)<BR> Dim i As Integer<BR> i = Len(bar)<BR> End Sub<BR><BR>In fact, LEN() allows you to take the length of most anything, returning the number of bytes occupied by its argument. For example:<BR> Dim dbl As Double<BR> Dim i As Integer<BR> i = Len(dbl)<BR>will handily put the value 8 into i.<BR><BR>Anyway, LEN() *should* be part of the Microsoft.VisualBasic namespace, I would think. Oh, never mind...let me check.<BR><BR>Yeah:<BR> Dim i As Integer<BR> i = Microsoft.VisualBasic.Len(i)<BR>works like a charm.<BR><BR>So if you are using VB.NET, I suspect some other problem.<BR><BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: A basic question: Len ( )

    stringName.length<BR><BR>will work in both languages

Posting Permissions

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