Coffeehouse Thread

10 posts

Guess what this thread is all about

Back to Forum: Coffeehouse
  • henningms

    The thread is about me needing help (again) Wink

    Want to say thanks for all of you that have helped me before, this community is great!

    Back to the topic, is there a way to find out how many entries there is in a Array?

    Dim splCommand() As String

    Then I want to loop through the Array by 1 so it displays splCommand(1), splcommand(2) and so on until there is no more "text" left.

    Language is ofcourse Visual Basic .NET

    Thanks! Big Smile

  • Manip

    for x = lbound(splCommand) to ubound(splCommand) 
       if not splCommand(x) = "" then 
          msgbox splCommand(x) 
       end if
    next x

  • Sampy

    Also:

    1.0:
    Dim x As String
    For Each x in splCommand
       If Not x = "" Then
          MsgBox(x)
       End If
    End For

    1.1 and beyond:
    For Each x As String In splCommand
       If Not x = "" Then
          MsgBox(x)
       End If
    End For

  • harumscarum

    Is  x.Equals("") any more effecient then x="" ?

  • Sampy

    I'd have to dig a little deeper into the IL (I'm on the deployment team, not the compiler) but I would imagine they are the same.

    However, these kinds of "optimizations" aren't really going to help you improve performance at all.

  • henningms

    Thanks, I have another question.. Scripting Runtime works in VB.NET aswell? And if, can you show me a example. I am travelling tomorrow, to Cyprus (holiday) and I am taking my Pocket PC with me and I want to make my app to run code from a file. Thanks again!

  • harumscarum

    We have a code analysis tool  and I believe this is one of the things it flagged. Myself and another developer discussed  this somewhat and wondered if this makes it any faster. I guess it is the same thought of usingString.Compare("a","b") instead of  "a"="b". In the analysis tool it actual says this way is faster.

  • Manip

    I would have thought that Equals() has to do a comparison operation anyway, and assuming that the compiler/pre-processor doesn't replace it that means your adding extra unnecessary overhead to a comparison.
     
    Just as a note, I use a For loop as opposed to the For Each because it means you can navigate and alter the array items.

    myArray(X) = NewValue
    myArray(X - 1) = BeforeNewValue
    myArray(X + 1) = AfterNewValue

  • henningms

    Yeah, it's very important to be _able_ to change the current item or do some other stuff to it than just check it.

    But, as I asked before - is scripting still supported? I really need to have it, or else I go in two weeks wondering if the code I wrote in Word will work. It still work and does it work on Pocket PCs ?

  • gmiley

    Speaking of comparisons, I scanned an article today about problems with VB.Net diverging from the .Net framework to, supposedly, accomodate old VB programmers. It has to do with Stacks and Heaps. I forget what it was, I have the article at work, ill put more info up on here about it tomorrow.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.