[dba-VS] C#, mantissa, math fun
Jim Lawrence
accessd at shaw.ca
Mon Oct 16 13:40:30 CDT 2017
Hi Gustav:
It sounds like you are doing some very exciting stuff. I have been sort of retired but once I start application development I am totally hyped.:-)
I will be working on an Access xx conversion from MDB to MS SQL. (Might need your help at some time.) The current code is a mess with little documentation and with all sorts of product hacks that make the system very difficult to upgrade. After the database migration, the next part of the project will be to replace Access with a browser FE. It will first run as an intranet app but eventually it will be migrated to the internet.
Right now, a friend and I, are working on an initial installation of a product called "Big Blue Button"...It is supposed to be replacing a $500K existing application. BBB is a huge open source application that is targeted towards local/distant-education but it would work equally as well as a company management tool. We got the program up and running in a Ubuntu 17.04 instance running on a MS Hyper-V server. It will probably take a good month of tests and then we deploy the system up to a DigitalOcean droplet and at one point a major roll-out. All very heady stuff. I will post the base BBB install over-view on the DBA-Tech list later today.
Aside: It is no longer just being able to code but being able to secure a site. I find all the new security management that must be applied to all new application challenging. My friend's company may be hiring a tech solely for that purpose...an edge protection expert.
Keep me posted on your progress.
Jim
----- Original Message -----
From: "Gustav Brock" <gustav at cactus.dk>
To: "Development in Visual Studio" databaseadvisors.com>
Sent: Monday, October 16, 2017 10:52:28 AM
Subject: Re: [dba-VS] C#, mantissa, math fun
Hi Jim
Right now I'm about converting three old Access 97 apps to Access 2016 with a SQL Server 2017 backend.
Initially, it's quite easy: Convert FE and BE to Access 2000 and relink. Then convert these to Access 2016 and relink.
Now, use SSMA to migrate the backend to SQL Server. Finally, relink FE to the SQL Server database via the SQL Server 13 driver.
With minor changes, this runs directly with a local SQL Server. But if running across a WAN, the fun begins.
However, this client will have a local SQL Server 2017 Express running, so it might very well stay at this step.
I have also built a larger budgetting application in Excel for a TV production company linking actual data from their ERP system. This has no interface, so I had to build a conversion app (in C#) to link the old Access backend of the system directly and copy data to a local SQL Server - and push the data further on to Azure SQL. This is because the budget app has to run in Excel Online, thus no macros, neither access to "foreign" data sources, only Azure.
This was a bit of a challenge, as I could only get Excel to connect to Azure SQL via OLEDB, and - because of no VBA - all "logic" had to be by formulas.
I ended up to build the entire workbook, worksheets, tables, connections, table design, formulas, and the full graphic design including hyperlinks and table styles from code.
To accomplish this was a major task, as so little useful code can be found; most code is GUI oriented and deals with selections, A1:G6 styling, no Named Ranges, and - in general - is sloppish and "good enough". Add to this the mediocre documentation of Excel VBA and you feel you are on your own.
I ended up with a large library of both common and specific functions. By running a series of a dozen or so functions I can build the entire application in two steps from an empty workbook: First step creates all the connections and base tables. Then, due to a bug in Excel, Excel has to be closed completely and relaunched. Second step builds the entire application in twenty seconds. It looks quite impressive.
Perhaps I should publish the work - if for nothing else to demonstrate how VBA could and should be handled in Excel. But I cannot find out where.
Sadly, I have had too little time to program in C#, my favourite. I hope this will change now.
/gustav
________________________________________
Fra: dba-VS databaseadvisors.com> på vegne af Jim Lawrence <accessd at shaw.ca>
Sendt: 16. oktober 2017 19:11
Til: Development in Visual Studio
Emne: Re: [dba-VS] C#, mantissa, math fun
Hi Gustav:
I have always been really anal when it comes to programming as I have been bit so many times...it now a habit.
So what projects are you now working on?
Jim
----- Original Message -----
From: "Gustav Brock" <gustav at cactus.dk>
To: "Development in Visual Studio" databaseadvisors.com>
Sent: Monday, October 16, 2017 10:08:03 AM
Subject: Re: [dba-VS] C#, mantissa, math fun
Hi Jim
I'm lazy, so the default value of variable Result - a zero length string - is returned if the passed parameter fails the IsNumeric check or if variable Fraction is zero.
/gustav
________________________________________
Fra: dba-VS databaseadvisors.com> på vegne af Jim Lawrence <accessd at shaw.ca>
Sendt: 16. oktober 2017 18:43
Til: Development in Visual Studio
Emne: Re: [dba-VS] [dba-VB] C#, mantissa, math fun
Hi Gustav:
Thanks for the update. I have a question about the return parameters. As it is possible to send any value to this function, how are values like strings or an empty value managed? Should the variable "Result" be initialized to a zero or have some other default value?
Jim
----- Original Message -----
From: "Gustav Brock" <gustav at cactus.dk>
To: "Development in Visual Studio" databaseadvisors.com>, "Access Developers discussion and problem solving" <accessd at databaseadvisors.com>
Sent: Monday, October 16, 2017 3:33:49 AM
Subject: Re: [dba-VS] [dba-VB] C#, mantissa, math fun
Hi all
Oops, the parameter should be a Variant to take a Decimal value which can hold op to 28 decimals:
' Returns the mantissa of a decimal number as
' a string to preserve leading zeroes.
'
' Maximum returned length of mantissa is:
' Single: 8
' Double: 16
' Currency: 4
' Decimal: 28
'
' Examples:
' Mantissa(1234.56789) -> "56789"
' Mantissa(-1234.56789) -> "56789"
' Mantissa(1234.056789) -> "056789"
' Mantissa(-1234.056789) -> "056789"
' Mantissa(123456789) -> ""
' Mantissa(CDec("-0.0123456789012345678901234567")) -> "0123456789012345678901234567"
' Mantissa(CDbl("-0.0123456789012345678901234567")) -> "0123456789012346"
'
' 2017-10-16. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function Mantissa( _
ByVal Number As Variant) _
As String
Dim Result As String
Dim Fraction As Variant
If IsNumeric(Number) Then
' Convert to Decimal to prevent scientific notation of doubles and singles.
Fraction = CDec(Number) - Fix(CDec(Number))
If Fraction <> 0 Then
Result = Mid(Str(Abs(Fraction)), 3)
End If
End If
Mantissa = Result
End Function
/gustav
-----Oprindelig meddelelse-----
Fra: dba-VS [mailto:dba-vs-bounces at databaseadvisors.com] På vegne af Gustav Brock
Sendt: 15. oktober 2017 17:54
Til: Development in Visual Studio databaseadvisors.com>; Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Emne: Re: [dba-VS] [dba-VB] C#, mantissa, math fun
Hi all
I posted a method for this in C#.
Finding the mantissa in VBA it could be like:
' Returns the mantissa of a decimal number as ' a string to preserve leading zeroes.
'
' Examples:
' Mantissa(1234.56789) -> "56789"
' Mantissa(-1234.56789) -> "56789"
' Mantissa(1234.056789) -> "056789"
' Mantissa(-1234.056789) -> "056789"
' Mantissa(123456789) -> ""
'
' 2017-10-15. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function Mantissa( _
ByVal Number As Double) _
As String
Dim Result As String
Dim Fraction As Variant
Fraction = CDec(Number) - CDec(Fix(Number))
If Fraction <> 0 Then
Result = Mid(Str(Abs(Fraction)), 3)
End If
Mantissa = Result
End Function
/gustav
_______________________________________________
dba-VS mailing list
dba-VS at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vs
http://www.databaseadvisors.com
More information about the dba-VS
mailing list