Conversions

PoweRoy
Member Posts: 43
2 bad my other 2 topics arent solved yet but i bumped to another one.
note: programmed in c#.net
i use the stringbuilder to collect data from the database using cfront.dll (see here)
but i have some troubles with the conversions (aka not getting the results i should have)
so i made a small program to give a string, and transform it and then back again.
the functions that are available in cfront.dll and how i used them:
//textBox1 is the input and textBox2 the output
bcd_2_str
result: "0,00000000000000000000000000343332"
str_2_bcd
result: "C" output: %
[Dlbcd_2_double[/b] //note i use the stringbuilder cause if i used as 1param a double i didnt get anything
result: "OyØ1Øÿp:"
[Dldouble_2_bcd[/b]
result: error inputstring was not in a correct format
[Dldate_2_str[/b]
result: "U11-06-1697" <-- always gives this in return
[Dlstr_2_date[/b]
result: object reference not set to an instance of an object
Where does it go wrong and what is a sollution
thx in advance!
note: programmed in c#.net
i use the stringbuilder to collect data from the database using cfront.dll (see here)
but i have some troubles with the conversions (aka not getting the results i should have)
so i made a small program to give a string, and transform it and then back again.
the functions that are available in cfront.dll and how i used them:
//textBox1 is the input and textBox2 the output
bcd_2_str
[DllImport("cfront.dll", CallingConvention = CallingConvention.Cdecl)] private static extern void DBL_BCD_2_Str(System.Text.StringBuilder _string, int strLength, string deciStr);
//bcd to string System.Text.StringBuilder sbuilder = new System.Text.StringBuilder(35); DBL_BCD_2_Str(sbuilder,35,textBox1.Text); textBox2.Text = sbuilder.ToString();input: "1234"
result: "0,00000000000000000000000000343332"
str_2_bcd
[DllImport("cfront.dll", CallingConvention = CallingConvention.Cdecl)] private static extern void DBL_Str_2_BCD(System.Text.StringBuilder _string, string dateStr);
//string to bcd System.Text.StringBuilder sbuilder = new System.Text.StringBuilder(35); DBL_Str_2_BCD(sbuilder,textBox1.Text); textBox2.Text = sbuilder.ToString();input: "1234" other input: 0,00000000000000000000000000343332 (result bcd_2_str)
result: "C" output: %
[Dlbcd_2_double[/b] //note i use the stringbuilder cause if i used as 1param a double i didnt get anything
[DllImport("cfront.dll", CallingConvention = CallingConvention.Cdecl)] private static extern void DBL_BCD_2_Double(System.Text.StringBuilder _value, string bcdstr);
//bcd to double System.Text.StringBuilder sbuilder = new System.Text.StringBuilder(35); DBL_BCD_2_Double(sbuilder,textBox1.Text); textBox2.Text = Convert.ToString(sbuilder.ToString());input: "1234"
result: "OyØ1Øÿp:"
[Dldouble_2_bcd[/b]
[DllImport("cfront.dll", CallingConvention = CallingConvention.Cdecl)] private static extern void DBL_Double_2_BCD( string bcdstr, double _value);
//double to bcd string getal = ""; DBL_Double_2_BCD(getal,Convert.ToDouble(textBox2.Text)); textBox2.Text = getal;input: "1234"
result: error inputstring was not in a correct format
[Dldate_2_str[/b]
[DllImport("cfront.dll", CallingConvention = CallingConvention.Cdecl)] private static extern void DBL_Date_2_Str(System.Text.StringBuilder _string, int strLength, string dateStr);
//date to string System.Text.StringBuilder sbuilder = new System.Text.StringBuilder(35); DBL_Date_2_Str(sbuilder,35,textBox1.Text); textBox2.Text = sbuilder.ToString();input: any date
result: "U11-06-1697" <-- always gives this in return
[Dlstr_2_date[/b]
[DllImport("cfront.dll", CallingConvention = CallingConvention.Cdecl)] private static extern void DBL_Str_2_Date(System.DateTime date, string dateStr);
//string to date System.DateTime datum = new System.DateTime(); DBL_Str_2_Date(datum,textBox1.Text); textBox2.Text = Convert.ToString(datum);input: Any date
result: object reference not set to an instance of an object
Where does it go wrong and what is a sollution
thx in advance!
0
Comments
-
you can call to the function with:
StringBuilder sbuilder = new StringBuilder();
DBL_BCD_2_Str(sbuilder,35,textBox1.Text);
textBox2.Text = sbuilder.ToString();
i think that the string builder is buid dynamic and if you put the length the string builder fill with ceros.
i hope that it's ok.Jacinto Aisa0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions