locked
vb problem RRS feed

  • Question

  • User-1075092149 posted

    i don't know the following code, anyone help!~ (vb)

     If (Not ID.IndexOf("\") = -1) Then
                        arrID = Split(ID, "\")
    
                        If UBound(arrID) > 0 Then
                            m_DebugID = arrUserID(UBound(arrID))
                            Session("ID") = m_DebugID

    uBound?

    Wednesday, October 16, 2013 11:09 PM

Answers

  • User-417640953 posted

    Hi,

    As others mentioned, The function UBound returns the highest available subscript for the indicated dimension of an array.

    If arrays like below.

    Dim arrayTest1 As String() = New String() {"a", "b", "c"}
    Dim arrayTest2 As String() = New String() {"1", "2", "3", "4"}
    

    Then UBound(arrayTest1) is 2, UBound(arrayTest1) is 3. If we get value by the subscript.  arrayTest1(UBound(arrayTest1)) is "c" and arrayTest2(UBound(arrayTest2)) is "4".

    Hope this helps. Thanks.

     

    Best Regards!


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 21, 2013 5:50 AM

All replies

  • User2103319870 posted

    Hi,

    UBound function Returns the highest available subscript for the indicated dimension of an array.

    Parameters:

          Array

              Required. Array of any data type. The array in which you want to find the highest possible subscript of a dimension.

         Rank

             Optional. Integer. The dimension for which the highest possible subscript is to be returned. Use 1 for the first dimension, 2 for the second, and so on. If Rank is omitted, 1           is assumed.

    Return Value:

              Integer. The highest value the subscript for the specified dimension can contain. If Array has only one element, UBound returns 0. If Array has no elements, for example if             it is a zero-length string, UBound returns -1.

    Refer the below link


    Wednesday, October 16, 2013 11:11 PM
  • User-1075092149 posted

    for my coding provided on the first post.

    here is different cases, what is the result of Session("ID")??

    case 1:

    if i set ID="aaaa\bbb";

    what is the result of Session("ID")?

    is Session("ID")="bbb"?

    case 2:

    if i set ID="aaaa\bbb\ccc";

    what is the result of Session("ID")?

    is Session("ID")="ccc"?

    ubound to return the highest subscript that means the highest index of array it returns????

    If (Not ID.IndexOf("\") = -1) Then
                        arrID = Split(ID, "\")
    
                        If UBound(arrID) > 0 Then
                            m_DebugID = arrUserID(UBound(arrID))
                            Session("ID") = m_DebugID

    Thursday, October 17, 2013 11:20 AM
  • User-1075092149 posted

    for my coding provided on the first post.

    here is different cases, what is the result of Session("ID")??

    case 1:

    if i set ID="aaaa\bbb";

    what is the result of Session("ID")?

    is Session("ID")="bbb"?

    case 2:

    if i set ID="aaaa\bbb\ccc";

    what is the result of Session("ID")?

    is Session("ID")="ccc"?

    ubound to return the highest subscript that means the highest index of array it returns????

    If (Not ID.IndexOf("\") = -1) Then arrID = Split(ID, "\") If UBound(arrID) > 0 Then m_DebugID = arrUserID(UBound(arrID)) Session("ID") = m_DebugID

    anyone answer me?

    Friday, October 18, 2013 2:30 AM
  • User-417640953 posted

    Hi,

    As others mentioned, The function UBound returns the highest available subscript for the indicated dimension of an array.

    If arrays like below.

    Dim arrayTest1 As String() = New String() {"a", "b", "c"}
    Dim arrayTest2 As String() = New String() {"1", "2", "3", "4"}
    

    Then UBound(arrayTest1) is 2, UBound(arrayTest1) is 3. If we get value by the subscript.  arrayTest1(UBound(arrayTest1)) is "c" and arrayTest2(UBound(arrayTest2)) is "4".

    Hope this helps. Thanks.

     

    Best Regards!


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 21, 2013 5:50 AM