Questions

VB 6 covert to VB NET

Tags:
+
0 Votes
Locked

VB 6 covert to VB NET

jayobrien78
Hello,

I have the following line of code, but am not sure how to change it so that it works in VB NET. (It doesn't like the UCase(Right(strKey, section. Appreciate any help. jay

If UCase(strKey) = ".DEFAULT" Or UCase(Right(strKey, 8)) = "_CLASSES" Then
  • +
    0 Votes
    neil.duncan

    strKey.ToUpper().Substring(strKey.Length - 8,

    Does that do what you need?

    +
    0 Votes
    giadich

    the string object has some built in methods you could use for this:

    .ToUpper()
    .EndsWith()

    and you can also combine them like so:

    strKey.ToUpper.EndsWith("BLAH BLAH")

    +
    0 Votes
    aikimark

    If StrComp(strKey,".DEFAULT",vbCompareText)=0 Or StrComp(Right(strKey, 8),"_CLASSES",vbCompareText)=0 Then

    ============
    You might also rewrite the second comparison as
    strKey Like "*_CLASSES"

    ============
    You can rewrite the If statement as
    Select Case 0
    Case StrComp(strKey, ".DEFAULT", vbCompareText) , StrComp(Right(strKey, 8), "_CLASSES", vbCompareText)

    'Case Else 'optional equivalent to Else clause

    End Select

    +
    0 Votes
    Ayars

    I would use the following code, making use of the OrElse to minimise processing.

    If strKey.ToUpper = ".DEFAULT" OrElse strKey.ToUpper.EndsWith("_CLASSES") Then

  • +
    0 Votes
    neil.duncan

    strKey.ToUpper().Substring(strKey.Length - 8,

    Does that do what you need?

    +
    0 Votes
    giadich

    the string object has some built in methods you could use for this:

    .ToUpper()
    .EndsWith()

    and you can also combine them like so:

    strKey.ToUpper.EndsWith("BLAH BLAH")

    +
    0 Votes
    aikimark

    If StrComp(strKey,".DEFAULT",vbCompareText)=0 Or StrComp(Right(strKey, 8),"_CLASSES",vbCompareText)=0 Then

    ============
    You might also rewrite the second comparison as
    strKey Like "*_CLASSES"

    ============
    You can rewrite the If statement as
    Select Case 0
    Case StrComp(strKey, ".DEFAULT", vbCompareText) , StrComp(Right(strKey, 8), "_CLASSES", vbCompareText)

    'Case Else 'optional equivalent to Else clause

    End Select

    +
    0 Votes
    Ayars

    I would use the following code, making use of the OrElse to minimise processing.

    If strKey.ToUpper = ".DEFAULT" OrElse strKey.ToUpper.EndsWith("_CLASSES") Then