Re: convert to decimal type
You need to set the format of the cell that will contain the barcode to "Text". The usual
format is "General" and this automatically changes the display of large numbers to use e
notation.
Use the NumberFormat property with value "@" to set the affected cell to "text" format
before putting the Barcode in it.
Cheers,
-Elio
Re: convert to decimal type
Try sending it with a prefixed ' (single quote)
Re: convert to decimal type
as all the other columns are text, you could just set the format for the entire range, before transferring any data
vb Code:
With wsxl
If Not worksheetname = "" Then
.Name = worksheetname
End If
.range(.cells( 1, 1), .cells(therows, thecols)).numberformat = "@" ' set format of target range to text
End With
For introw = 1 To therows
For intcol = 1 To thecols
With MSHFlexGrid1
wsxl.Cells(introw + 14, intcol).Value = _
cstr(.TextMatrix(introw - 1, intcol - 1)) & " " ' convert all values to string, though only really required for column 1
End With
Next
Next
Re: convert to decimal type
hit it didn't work still 1.48099E+17 and if i double click the cell it will change to 148098765430000000 which is wrong it should be 148098765430000009.
Re: convert to decimal type
How can i stop it from rounding off?
Re: convert to decimal type
13 and 14 digit barcodes is working fine except for 18 digits it keeps rounding off. how can i stop this.
thanks!
Re: convert to decimal type
did you check the format of the cell?
as long as i work with strings i have no problem displaying the correct value
i get the double click effect if the cell is formatted general or other number
Re: convert to decimal type
With numeric values, Excel cells can handle with the precision of Double data type (maximum 15 accurate digits). This is a big problem for novice user who doesn't aware of.
I have seen people enter 16 consecutive digits of credit card into a cell then press enter and didn't know that the last digit was round off (even with format "0000000000000000", 16 zero's).
There is only one way to deal with this is to convert that numeric value to Text (String) and a safe way is to precede the value with a single quote ('), no worry abount the cell format.
Code:
If intcol = 2 then
wsxl.Cells(introw + 14, intcol).Value = "'" & .TextMatrix(introw - 1, intcol - 1)
Else
wsxl.Cells(introw + 14, intcol).Value = .TextMatrix(introw - 1, intcol - 1)
End If