Connection & Report call via ODBC and Number to Text

Connection:

Public Cnn As ADODB.Connection
Public strCn As String
Public crcon As String

Public Sub cnDb()
Dim strCn As String
Set Cnn = New ADODB.Connection
'strCn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=dbUCL;Data Source=DCLSERVER"
'strCn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=dbUCL;Data Source=dcl_db"
strCn = "Provider=MSDASQL.1;Persist Security Info=False;password=mm1234;User ID=sa;Data Source=gcl_db;"

'cn.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Password=sa;User ID=sa;Data Source=NUB_Tool;"

Cnn.Open strCn
End Sub
Public Function FTable(strT As String, rsA As ADODB.Recordset)
'Call cnDb
Set rsA = New ADODB.Recordset
rsA.Open strT, Cnn, adOpenKeyset, adLockOptimistic, adCmdTable
End Function
Sub main()
MDIfrmMain.Show
'frmLogin.Show 1
frmLogin_main.Show 1
End Sub
Public Function FSql(strS As String, rsA As ADODB.Recordset)
'Call cnDb
Set rsA = New ADODB.Recordset
rsA.Open strS, Cnn, adOpenKeyset, adLockOptimistic, adCmdText
End Function






Report:
Dim x As New islip 'IssueSlip


x.Text4.SetText (Sr)
x.Text6.SetText (xd)
x.Text10.SetText (dname)
x.Text12.SetText ("") '(ename)

x.PaperSize = crPaperLetter
x.VerifyOnEveryPrint = True
x.Database.LogOnServer "pdsodbc.dll", "gcl_db", "dbGCL", "sa", "mm1234"

With CRViewer1
.EnableGroupTree = False
.Zoom 100
.Top = 0
.Left = 0
.Height = Me.Height - 1000
.Width = Me.Width - 120
.ReportSource = x
.ViewReport
End With




Number to Text:
Public Function ConvertNumber(strNumber As String) As String

'====Converts a number to word===================

Dim tk As String
Dim paisa As String
Dim ten As String
Dim hund As String
Dim thou As String
Dim lac As String
Dim crore As String
Dim list(100) As String
Dim length As Integer
Dim lencr As Integer
Dim pointl As Integer
Dim croreten As String
Dim crorehund As String
Dim crorethou As String
Dim crorelac As String
Dim crorecr As String
Dim tkword As String


list(0) = ""
list(1) = "One"
list(2) = "Two"
list(3) = "Three"
list(4) = "Four"
list(5) = "Five"
list(6) = "Six"
list(7) = "Seven"
list(8) = "Eight"
list(9) = "Nine"
list(10) = "Ten"
list(11) = "Eleven"
list(12) = "Twelve"
list(13) = "Thirten"
list(14) = "Forteen"
list(15) = "Fifteen"
list(16) = "Sixteen"
list(17) = "Seventen"
list(18) = "Eighteen"
list(19) = "Ninteen"
list(20) = "Twenty"
list(21) = "Twenty One"
list(22) = "Twenty Two"
list(23) = "Twenty Three"
list(24) = "Twenty Four"
list(25) = "Twenty Five"
list(26) = "Twenty Six"
list(27) = "Twenty Seven"
list(28) = "Twenty Eight"
list(29) = "Twenty Nine"
list(30) = "Thirty"
list(31) = "Thirty One"
list(32) = "Thirty Two"
list(33) = "Thirty Three"
list(34) = "Thirty Four"
list(35) = "Thirty Five"
list(36) = "Thirty Six"
list(37) = "Thirty Seven"
list(38) = "Thirty Eight"
list(39) = "Thirty Nine"
list(40) = "Forty"
list(41) = "Forty One"
list(42) = "Forty Two"
list(43) = "Forty Three"
list(44) = "Forty Four"
list(45) = "Forty Five"
list(46) = "Forty Six"
list(47) = "Forty Seven"
list(48) = "Forty Eight"
list(49) = "Forty Nine"
list(50) = "Fifty"
list(51) = "Fifty One"
list(52) = "Fifty Two"
list(53) = "Fifty Three"
list(54) = "Fifty Four"
list(55) = "Fifty Five"
list(56) = "Fifty Six"
list(57) = "Fifty Seven"
list(58) = "Fifty Eight"
list(59) = "Fifty Nine"
list(60) = "Sixty"
list(61) = "Sixty One"
list(62) = "Sixty Two"
list(63) = "Sixty Three"
list(64) = "Sixty Four"
list(65) = "Sixty Five"
list(66) = "Sixty Six"
list(67) = "Sixty Seven"
list(68) = "Sixty Eight"
list(69) = "Sixty Nine"
list(70) = "Seventy"
list(71) = "Seventy One"
list(72) = "Seventy Two"
list(73) = "Seventy Three"
list(74) = "Seventy Four"
list(75) = "Seventy Five"
list(76) = "Seventy Six"
list(77) = "Seventy Seven"
list(78) = "Seventy Eight"
list(79) = "Seventy Nine"
list(80) = "Eighty"
list(81) = "Eighty One"
list(82) = "Eighty Two"
list(83) = "Eighty Three"
list(84) = "Eighty Four"
list(85) = "Eighty Five"
list(86) = "Eighty Six"
list(87) = "Eighty Seven"
list(88) = "Eighty Eight"
list(89) = "Eighty Nine"
list(90) = "Ninty"
list(91) = "Ninty One"
list(92) = "Ninty Two"
list(93) = "Ninty Three"
list(94) = "Ninty Four"
list(95) = "Ninty Five"
list(96) = "Ninty Six"
list(97) = "Ninty Seven"
list(98) = "Ninty Eight"
list(99) = "Ninty Nine"

tkword = ""
crore = ""
lac = ""
thou = ""
hund = ""
ten = ""
crorecr = ""
crorelac = ""
crorethou = ""
crorehund = ""
croreten = ""
ConvertNumber = ""
lencr = 0

pointl = InStr(1, strNumber, ".", vbTextCompare)


If pointl > 0 Then
tk = VBA.Mid(strNumber, 1, pointl - 1)
paisa = VBA.Mid(strNumber, pointl + 1, Len(strNumber))
Else
tk = CStr(Val(strNumber))
End If
length = Len(tk)

While length > 0
Select Case length
Case Is > 7: crore = VBA.Mid(tk, 1, length - 7)
tk = VBA.Mid(tk, length - 6, length)

Case Is > 5: lac = VBA.Mid(tk, 1, length - 5)
tk = VBA.Mid(tk, length - 4, length)

Case Is > 3: thou = VBA.Mid(tk, 1, length - 3)
tk = VBA.Mid(tk, length - 2, length)

Case Is > 2: hund = VBA.Mid(tk, 1, length - 2)
tk = VBA.Mid(tk, length - 1, length)

Case Is > 0: ten = tk
tk = ""

End Select
length = Len(tk)
Wend

If Val(crore) <> 0 And Val(crore) < 1000000000 Then

lencr = Len(crore)
length = Len(crore)
While length > 0
Select Case length
Case Is > 7: crorecr = VBA.Mid(crore, 1, length - 7)
crore = VBA.Mid(crore, length - 6, length)

Case Is > 5: crorelac = VBA.Mid(crore, 1, length - 5)
crore = VBA.Mid(crore, length - 4, length)

Case Is > 3: crorethou = VBA.Mid(crore, 1, length - 3)
crore = VBA.Mid(crore, length - 2, length)

Case Is > 2: crorehund = VBA.Mid(crore, 1, length - 2)
crore = VBA.Mid(crore, length - 1, length)

Case Is > 0: croreten = crore
crore = ""

End Select
length = Len(crore)
Wend

End If


If Val(crorecr) <> 0 Then
tkword = tkword + list(Val(crorecr)) + " Crore "
End If
If Val(crorelac) <> 0 Then
tkword = tkword + list(Val(crorelac)) + " Lac "
End If
If Val(crorethou) <> 0 Then
tkword = tkword + list(Val(crorethou)) + " Thousand "
End If

If Val(crorehund) <> 0 Then
tkword = tkword + list(Val(crorehund)) + " Hundred "
End If
If Val(croreten) <> 0 Then
tkword = tkword + list(Val(croreten)) + " Crore "
End If
If Val(croreten) = 0 And lencr > 0 Then
tkword = tkword + " Crore "
End If


If Val(lac) <> 0 Then
tkword = tkword + list(Val(lac)) + " Lac "
End If
If Val(thou) <> 0 Then
tkword = tkword + list(Val(thou)) + " Thousand "

End If
If Val(hund) <> 0 Then
tkword = tkword + list(Val(hund)) + " Hundred "

End If
If Val(ten) <> 0 Then
tkword = tkword + list(Val(ten))

End If
ConvertNumber = tkword + " Taka "

If Val(paisa) <> 0 Then
ConvertNumber = ConvertNumber + " And " + list(Val(paisa)) + " Paisa "
End If

End Function