How to write a program to convert numbers into words in visual basic 6.0

How to convert numbers into words in visual basic

Are you looking for visual basic source code that will convert the numbers into words then here is the best solution for you. In this post, we are going to learn how to write a program to convert numbers into words in visual basic 6.0. Most of the students are searching for this program. Because of this type programs are asked in many types of exams, so we should not ignore this type of program. Below I have given easy source code and also given the project file of this program so that you can easily download this program and convert numbers into words.

A lot of students are finding the solution for the visual basic programs to convert numbers into words in vb6 but they can’t get an easy solution for their program due to they are not interested in visual basic programs. So, here we are able to provide an easy solution for your program. If you are interested in visual basic programming then join us here we are given free visual basic source code for visual basic programs examples. If you want to see our other visual basic programs example then you can see this program. How to display transpose of matrix in visual basic 6.0. Now here I have not mentioned more details in the form but you can add more features as your wish.

Write-a-program-to-convert-numbers-into-words-in-visual-basic-6

Before starting the program, I tell you that for converting numbers into words in visual basic 6 we need to understand how to work numbers and words in vb6. So, for this question, I will make a separate post. Still, nowhere I will give you a free source code for your program therefore don’t worry about that. For creating the program to convert numbers into words in vb6, just follow the following steps and after that, you can easily make that program.

Steps for the program to convert numbers into words in visual basic 6.0

  1. First, create a new form
  2. Then draw three labels, in those labels two labels display information, and another one is for displaying the converted numbers into words.
  3. After that draw three buttons, one label is for converting the numbers to words another one is for clear entered in displayed information, and one button exits the form.
  4.  Then write the code on buttons (source code is given below, there are separate sources for each button)
  5. After that right-click on the main form, & add a new module, and write the given code on that module.
how-to-convert-amount-in-to-words-in-vb6


      6. Then run the program.

Source code for the main form to convert numbers into words in visual basic 6

Option Explicit

 

Private Sub Command1_Click()

lblNumToWords.Caption = ""

txtNumber.Text = ""

End Sub

 

Private Sub txtNumber_GotFocus()

With txtNumber

.SelStart = 0

.SelLength = Len(.Text)

End With

End Sub

 

Private Sub txtNumber_KeyPress(KeyAscii As Integer)

If KeyAscii = vbKeyBack Then Exit Sub

If InStr("0123456789", Chr$(KeyAscii)) = 0 Then

KeyAscii = 0

End If

End Sub

 

Private Sub txtNumber_Change()

lblNumToWords = ""

End Sub

 

Private Sub cmdDoIt_Click()

lblNumToWords = NumToWords(txtNumber)

End Sub

 

Private Sub cmdExit_Click()

End

End Sub

Source code for a module to convert numbers into words

Option Explicit

 

Function NumToWords(strNumberString As String) As String

Dim intGroupX           As Integer

Dim intUnitDigit        As Integer

Dim intTensDigit        As Integer

Dim intHundDigit        As Integer

Dim intGroupStartPos    As Integer

Dim intNbrLeadingZeros  As Integer

Dim intX                As Integer

Dim strWorkNumber       As String

Dim strGroupVerbage     As String

Dim arrUnitName         As Variant

Dim arrCompoundName     As Variant

Dim arrTensName         As Variant

Dim arrGroupName        As Variant

   

arrUnitName = Array("", "One", "Two", "Three", "Four", "Five", _

                        "Six", "Seven", "Eight", "Nine")

arrCompoundName = Array("", "Eleven", "Twelve", "Thirteen", _

                            "Fourteen", "Fifteen", "Sixteen", _

                            "Seventeen", "Eighteen", "Nineteen")

arrTensName = Array("", "Ten", "Twenty", "Thirty", "Forty", _

                        "Fifty", "Sixty", "Seventy", "Eighty", _

                        "Ninety")

arrGroupName = Array("", "Thousand", "Million", "Billion", _

                         "Trillion", "Quadrillion", "Quintillion", _

                         "Sextillion", "Septillion", "Octillion", _

                         "Nintillion", "Decillion")

                        

If Not IsAllDigits(strNumberString) Then

MsgBox "Numeric argument required.", vbInformation, _

"Invalid Argument"

NumToWords = ""

Exit Function

End If

   

If Len(strNumberString) > 36 Then

MsgBox "Argument must not exceed 36 digits.", vbInformation, _

"Argument Too Big"

NumToWords = ""

Exit Function

End If

   

intNbrLeadingZeros = 36 - Len(strNumberString)

strWorkNumber = strNumberString

For intX = 1 To intNbrLeadingZeros

strWorkNumber = "0" & strWorkNumber

Next

   

intGroupStartPos = 34

For intGroupX = 0 To 11

intUnitDigit = Val(Mid$(strWorkNumber, intGroupStartPos + 2, 1))

intTensDigit = Val(Mid$(strWorkNumber, intGroupStartPos + 1, 1))

intHundDigit = Val(Mid$(strWorkNumber, intGroupStartPos, 1))

If intUnitDigit = 0 And intTensDigit = 0 Then

strGroupVerbage = ""

ElseIf intUnitDigit = 0 Then

strGroupVerbage = arrTensName(intTensDigit)

ElseIf intTensDigit = 1 Then

strGroupVerbage = arrCompoundName(intUnitDigit)

ElseIf intTensDigit = 0 Then

strGroupVerbage = arrUnitName(intUnitDigit)

Else

strGroupVerbage = arrTensName(intTensDigit) & "-" _

& arrUnitName(intUnitDigit)

End If

If intHundDigit <> 0 Then

strGroupVerbage = arrUnitName(intHundDigit) & " Hundred " _

& strGroupVerbage

End If

If strGroupVerbage <> "" Then

strGroupVerbage = strGroupVerbage & " " _

& arrGroupName(intGroupX)

End If

NumToWords = strGroupVerbage & " " & NumToWords

intGroupStartPos = intGroupStartPos - 3

Next

NumToWords = Trim$(NumToWords)

If NumToWords = "" Then NumToWords = "ZERO"

End Function

 

Function IsAllDigits(strTestString As String) As Boolean

Dim intX    As Integer

For intX = 1 To Len(strTestString)

If InStr("0123456789", Mid$(strTestString, intX, 1)) > 0 Then

' continue

Else

IsAllDigits = False

Exit Function

End If

Next

IsAllDigits = True

End Function
vb6-convert-number-to-words

Why do you need to write a visual basic program that converts numbers into words in vb6?

Yes! Yes, I know that nowadays there are a lot of solutions available for this program but I think most of the students are not satisfied with that solutions, therefore, I have tried to provide an easy solution for you. By using this solution you can easily convert numbers or amounts into words. Now here we are going to see why we need a visual basic program to convert numbers into words.

Mainly this program is very useful for college students who are learning visual basic programming. In this program, you can know how to work numbers operation in vb6. Sometimes many students think that this program is not useful for us because they are confused in is it still worth learning visual basic 6.0? But, if you are BCA or computer science student then you can understand the value of these types of visual basic programs examples.

This program will very helpful for developing banking applications. For example in the bank when we want to withdraw money then we are filling the slip in that slip we are entering the money amount in numbers as well as words, If there are we use this type of logic in software then that will very helpful for many peoples. If you know properly how to convert numbers into words in vb6 then you can use the logic of this program in other programming languages like c,c++, PHP, etc.

Program-to-convert-numbers-into-words-in-visual-basic-6

How to work this visual basic program to convert numbers into words

The working flow of this program is very easy. You want to just enter the numbers in the textbox and then click on the convert button after that the numbers will be automatically converted to words. If you want to know the coding flow of this program then I will provide another separate video for you. If you want the video for this post then comment to me.

Most of the time this program is asked in many exams but a lot of students don’t know how to convert numbers into words in vb6, therefore, they can’t solve this type of program. But don’t worry now because here I have given a very easy solution for you, just copy this source code and run your program. If you can’t copy this program then you can request me for the project file. Just fill out the contact form and give me your email.

I hope you get an easy solution for the program to convert numbers into words in visual basic 6.0. If you have any queries regarding this program then you can contact or comment on me.

program-to-convert-numbers-into-words-in-visual-basic


Download the source code for a program to convert numbers into words in visual basic 6 


Note: If the download link is not working then contact me through the contact form and send your email. I will send you the project file in your email.

Post a Comment

0 Comments