The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Text control display issue with Number: Input is 7.2 but output is 7.20000000009 
Posted: 09 Aug 10 7:20 AM
|
I am importing few number values from Excel to SLX using SLX Button control. For example, Please see the below sample values
Column 1
2.3.1 7.3.4 7.2 5.4.5 5.6
i am importing the above 5 values to 5 accounts. But the output is like this
2.3.1 7.3.4 7.20000000009 5.4.5 5.60000000009
I have tried with Format type and Format String. But i didnt get any solution. Please help me on this.
|
|
|
|
Re: Text control display issue with Number: Input is 7.2 but output is 7.20000000009 
Posted: 09 Aug 10 8:47 AM
|
??? THIS IS NOT A NUMBER: 2.3.1 THIS IS NOT A NUMBER: 7.3.4 7.2 THIS IS NOT A NUMBER: 5.4.5 5.6
You are complaining that 7.2 and 5.6 are not being imported incorrectly, yet these are the only valic numbers in your supplied sample dataset
What is the script code that you are using to read in these values?
what sort of field are you storing them in in the SQL Server database? |
|
|
|
Re: Text control display issue with Number: Input is 7.2 but output is 7.20000000009 
Posted: 09 Aug 10 9:10 AM
|
Hi Samp,
I am storing the value in SQL as String only. Because sometime it will be "1.2A" also.
The following steps, i am inserting the value into SLX DB.
1. i m just creating ("ADODB.Connection") object, 2. Through this object i am using "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=testexcel.xls;Extended Properties=Excel 8.0;" provider. 3. executing and setting the result to "testObj" 4. Through loop extracting the value and assing to "Testvar" 5. Creating slxObj for that particular table using SLX API 6. slxobj.AddNew 7. slxobj.Fields("TestField") = "TestVar" 8. slxobj.Update
Please give me your suggestion on this.
Regards K. Rajapandian.
|
|
|
| |
| |
|
Re: Text control display issue with Number: Input is 7.2 but output is 7.20000000009 
Posted: 10 Aug 10 6:07 AM
|
Dim TestConn, TestRS, TestSLXDB
Set TestSLXDB = New SLX_DB Set TestConn = CreateObject("ADODB.Connection")
TestConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = TextExcel.xls; Extended Properties = Excel 8.0;"
Set TestRS = TestConn.Execute("select * from [Sheet1$]")
With TestRS While Not (.EOF Or .BOF) InsertExcelValue(TestRS.Fields(0).Value) .MoveNext Wend .Close End With
Sub InsertExcelValue(TestVar)
Dim TestVar, TestObjInsertRS, strSQL Set TestObjInsertRS = TestSLXDB.GetNewRecordSet strSQL = "Select TestField from account where 1=2" TestObjInsertRS.Open strSQL, TestSLXDB.Connection
TestObjInsertRS.AddNew TestObjInsertRS.Fields("TestField") = TestVar TestObjInsertRS.Update
TestObjInsertRS.Close Set TestObjInsertRS = Nothing End Sub
|
|
|
| |
|
Re: Text control display issue with Number: Input is 7.2 but output is 7.20000000009 
Posted: 10 Aug 10 7:52 AM
|
Excel does its own formatting...you need to put an apostrophe before every item in this column IN the Excel spreadsheet.
7.2.3 is not a number.
7.2 IS definitely a number and Excel will supply the numeric double\real number value to your routine's ADO recordset. If the answer is 7.20000009 then there you go. No Format or cSTR function will save you.
We see this all of the time with US Postal Codes. 53562 is a valid postal code. 06815 is a valid postal code, EXCEL says it's 6,815.
You need to start running Debug Viewer and using Application.Debug.Writeline in your code to see what is going on.
Sure TESTVAR is a variant, (aren't ALL vbscript values, you want to know its sub type!!!), but what is its value? If the answer is 7.20000009 then that's what is going to be stored.....whether it's a number or not. |
|
|
|