Micro Focus QTP (UFT) Forums
Need to Format Variables Correctly - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Need to Format Variables Correctly (/Thread-Need-to-Format-Variables-Correctly)



Need to Format Variables Correctly - MichaelS - 11-15-2011

I am comparing two sorted excel files "acct" and "Crystal" and merging there contents into a third. I sorted the two excel files on two common fields in each. - Account number and and amount. I am trying to compare these two fields to see if there are differences between the two excel files, but the format I am getting is not the same that was use to sort the columns in the excel files. I would like the amount fields fixed and the account field to have leading zeroes so that the compare determines if there if found an extra accouting or crystal records and increments accordingly.

The amount field shows 0000001924.00 in excel, but the variable that I assigned from the cell had "1924". The Account field has leading zeroes and shows as such in excel, but the var does not have a leading zero. Can this be done or should I approach this problem differently?
Code:
Do until EndofBothFiles = true
    sAcctCustNBR= xlSheet.Rows(iARow).Columns(8)
    sCrystalCustNBR = xlSheet3.Rows(iCRow).Columns(8)
    sAcctAmount = xlSheet.Rows(iARow).Columns(2)
    sCrystalAmount = xlSheet3.Rows(iCRow).Columns(7)
    sAcctKey = sAcctCustNBR & sAcctAmount
    
    If sAcctKey = sCrystalKey Then
           'Move accounting and crystal fields to new speadsheet            
       iARow = iARow+1
       iCRow = iCRow+1
       iRow = iRow+1
    elseif sAcctKey < sCrystalKey  Then
      ' move accouning fields to new spreadsheet
       iARow = iARow+1
             iRow = iRow+1
    else
       'move crystal fields to new spreadsheet
       iCRow = iCRow+1
             iRow = iRow+1
    End If
    If iARow >= iAcctRowCount and iCRow >= iCrystalRowCount Then
       EndofBothFiles=True
    End If
Loop