Based on Excel Vba from http://www.excelforum.com/excel-programming/482390-excel-vba-calculating-checksums.html
?IsLuhnChecksumOK("0000000000000000")
Function IsLuhnChecksumOK(Number_String)
Local Digit
Local i
Local N
Local Result
Local SumDigits
Local nDigits
N = 0
SumDigits = 0
nDigits = Len(Number_String)
For i = nDigits To 1 Step -1
Digit = Val(Substr(Number_String, i, 1))
N = N + 1
If Mod(N , 2) = 0
Digit = Digit * 2
Endif
If Digit > 9
Digit = Digit - 9
Endif
SumDigits = SumDigits + Digit
Next i
Result = Mod(SumDigits ,10)
Return Result = 0
Endfunc
Function GetLuhnCheckDigit(Number_To_Check)
Local J As Integer
Local X
X = IsLuhnChecksumOK(Number_To_Check)
If X = False Then
For J = 0 To 9
X = IsLuhnChecksumOK(Bitand(Number_To_Check , J))
If X = True
*'Check digit found
*GetLuhnCheckDigit = J
Return J
Endif
Next J
Else
*'No check digit needed returns -1
Return -1
Endif
Endfunc
Thursday, October 14, 2010
Friday, October 1, 2010
NHibernate.Driver.SQLite20Driver Exception
To fix below error, make sure to add reference System.Data.Sqlite and Copy Local = True in the properties window.
FluentNHibernate.Cfg.FluentConfigurationException : An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
* Database was not configured through Database method.
----> NHibernate.HibernateException : Could not create the driver from NHibernate.Driver.SQLite20Driver.
----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
----> NHibernate.HibernateException : The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use element in the application configuration file to specify the full name of the assembly.
FluentNHibernate.Cfg.FluentConfigurationException : An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
* Database was not configured through Database method.
----> NHibernate.HibernateException : Could not create the driver from NHibernate.Driver.SQLite20Driver.
----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
----> NHibernate.HibernateException : The IDbCommand and IDbConnection implementation in the assembly System.Data.SQLite could not be found. Ensure that the assembly System.Data.SQLite is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use
Tuesday, July 27, 2010
Excel last row column
lnLastRow = loExcel.activesheet.UsedRange.ROWS.COUNT
lnLastCol = loExcel.activesheet.UsedRange.COLUMNS.COUNT
lnLastCol = loExcel.activesheet.UsedRange.COLUMNS.COUNT
Monday, July 26, 2010
Excel Fit to page using Foxpro Automation
loExcel.ActiveSheet.PageSetup.Zoom = .f.
loExcel.ActiveSheet.PageSetup.FitToPagesWide = 1
loExcel.ActiveSheet.PageSetup.FitToPagesTall = 1
loExcel.ActiveSheet.PageSetup.FitToPagesWide = 1
loExcel.ActiveSheet.PageSetup.FitToPagesTall = 1