将vb.net转换为旧的Visual Basic 6.0代码

我将代码从c#转换为vb.net。现在我需要将代码转换为Visual Basic 6.0

任何人都可以帮忙进行此转换吗?

<div class="clearfix">
  <div class="box margin-right" style="background-color:#bbb">
    <h1>
      Header1
    </h1>
    <div class="border">
      <h3>
        Container1
      </h3>
      Some text inside the box. Some text inside the box. Some text inside the box.
    </div>
  </div>
  <div class="box margin-left" style="background-color:#ccc">
    <h1>
      Header2
    </h1>
    <div class="border">
      <h3>
        Container2
      </h3>
      Some text inside the box.
    </div>
  </div>
</div>
XUQIAN28 回答:将vb.net转换为旧的Visual Basic 6.0代码

假设它将在模块中,则可以删除Shared关键字。

Public Function DigitoM10(ByVal pIntNumero As Double,ByVal pIntPersonaliza As Long) As Long
    Dim intPesos As Variant
    Dim strText As String
    Dim intSuma As Long,intIdx As Long,intPos As Long

    intPesos = Array(2,1,2,1)
    strText = Format$(pIntNumero,"0")
    If Len(strText) > 16 Then
        Err.Raise ErrorValueEnum.adErrInvalidArgument,"DigitoM10","Número no soportado para cálculo del dígito verificador"
    End If

    intSuma = 0
    intIdx = LBound(intPesos)

    For intPos = Len(strText) To 1 Step -1
        intSuma = intSuma + CLng(Mid$(strText,intPos,1)) * intPesos(intIdx)
        intIdx = intIdx + 1
    Next

    intSuma = intSuma Mod 10
    intSuma = 10 - intSuma

    If intSuma = 10 Then
        intSuma = 3
    End If

    DigitoM10 = intSuma + pIntPersonaliza
End Function

我不得不改变很多事情。 VB6通常不支持strText.Length中的点符号。请改用Len(strText)Err.Raise引发异常。

请注意,.NET中的Long是64位整数,在VB6中不可用。 .NET Integer是VB6 Long。因此,我声明了pIntNumero As Double并使用Format$(pIntNumero,"0")对其进行了格式化,以将其转换为字符串,否则,使用CStr()可能会将其切换为指数格式。直到15位数字有效。如果需要16位数字,请直接将数字作为字符串提供

Public Function DigitoM10(ByVal strText As String,ByVal pIntPersonaliza As Long) As Long

然后您可以删除行

strText = Format$(pIntNumero,"0")

在.NET中,可以像在strText(intPos)中一样对字符串进行索引以检索单个字符。这是通过VB6中的Mid$函数完成的。

还请注意,在.NET中,数组始终基于零。也就是说,第一个索引是0。在VB6 / VBA中,它们通常基于1,但是可以更改。请参阅:Option Base statementDeclaring arrays (VBA)。请注意,VB6和VBA是在不同环境中运行的相同语言。

使用已知示例测试此方法!

本文链接:https://www.f2er.com/3088890.html

大家都在问