Link to home
Create AccountLog in
Avatar of chokka
chokkaFlag for United States of America

asked on

Migrating VBA Macro Syntax to VB.Net

Below function splits comma values stored in a string variable. And also splits Currency value such as $1,000.00 by considering as one value. Original version of the code is written in VBA Macro which i am trying to convert to VB.Net.

I don't know to migrate only this piece of VBA Syntax

strRecord = Left(strRecord, intIndex - 1) & strTemp & Mid(strRecord, intPosEnd)

Complete VB.Net Syntax.

Dim strRecord As String
        Dim intIndex As Integer
        Dim intPosComma As Integer
        Dim intPosEnd As Integer
        Dim strTemp As String

        strRecord = " 1,1, " & "$1,182,100.58" & " ," & "$1,182.58" & " "

        For intIndex = 1 To Len(strRecord)
            If Mid(strRecord, intIndex, 1) = "$" Then
                intPosEnd = InStr(intIndex, strRecord, ".")
                strTemp = Mid(strRecord, intIndex, intPosEnd - intIndex)
                strTemp = Replace(strTemp, ",", "|")
                MessageBox.Show(strTemp)

                Dim strTemp2 As String

                strTemp2 = strRecord.Substring(1, intIndex - 1)

                MessageBox.Show(strTemp2)
                'strRecord = Left(strRecord, intIndex - 1) & strTemp & Mid(strRecord, intPosEnd)

            End If
        Next

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of chokka

ASKER

thanks !!