วิธี เขียน ตัวเลข เป็น ตัวหนังสือ: นี่คือโพสต์ที่เกี่ยวข้องกับหัวข้อนี้
- Details
- Hits: 32788
จากบทความก่อนนี้ Excel สูตรแปลงตัวเลขเป็นตัวหนังสือหรือตัวอักษรภาษาไทยด้วย BAHTTEXT() ผมได้แนะวิธีการแปลงตัวเลขเป็นตัวอักษรหรือคำอ่านที่เป็นภาษาไทยไปแล้ว ด้วยการใช้ BAHTTEXT() เพื่อนำไปใช้กับงานอย่างบัญชี ออก Invoice หรือ PO หรือ พิมพ์เช็ค บทความนี้จะเป็นการแปลงตัวเลขเป็นตัวอักษรคำอ่านภาษาอังกฤษกันบ้างครับ
โปรแกรม Excel จะไม่มีฟังก์ชันมาให้ใช้งานเหมือนอย่างการแปลงตัวเลขเป็นตัวอักษรคำอ่านภาษาไทยนะครับ เราต้องสร้างฟังก์ชันขึ้นมาใช้งานเองครับด้วย Microsoft Visual Basic for Applications ที่มาพร้อมกับ Excel ซึ่งโค้ดคำสั่งผมเอามาจาก https://support.microsoft.com แล้วนำมาปรับเพื่อให้สามารถใช้ได้กับหน่วยเงินของไทย
Table of Contents
เริ่มต้นสร้างฟังก์ชันแปลงตัวเลขเป็นคำอ่านภาษาอังกฤษ
ก่อนอื่นเปิดโปรแกรม Excel ขึ้นมาก่อน แล้วกดปุ่ม ALT + F11 บนคีย์บอร์ดเพื่อเปิด Visual Basic Editor ขึ้นมา จากนั้นไปที่เมนู Insert => Module ดังภาพด้านล่าง
จากนั้น Copy โค้ดด้านล่างนี้ไปวางที่หน้าต่างด้านขวา ดังภาพด้านบน
Option Explicit
‘Main Function
Function SpellNumber(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = ” Thousand “
Place(3) = ” Million “
Place(4) = ” Billion “
Place(5) = ” Trillion “
‘ String representation of amount.
MyNumber = Trim(Str(MyNumber))
‘ Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, “.”)
‘ Convert cents and set MyNumber to dollar amount.
If DecimalPlace > 0 Then
Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
“00”, 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace – 1))
End If
Count = 1
Do While MyNumber <> “”
Temp = GetHundreds(Right(MyNumber, 3))
If Temp <> “” Then Dollars = Temp & Place(Count) & Dollars
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) – 3)
Else
MyNumber = “”
End If
Count = Count + 1
Loop
Select Case Dollars
Case “”
Dollars = “No Baht”
Case “One”
Dollars = “One Baht”
Case Else
Dollars = Dollars & “Baht”
End Select
Select Case Cents
Case “”
Cents = ” Only”
Case “One”
Cents = ” and One Satang”
Case Else
Cents = ” and ” & Cents & ” Satang”
End Select
SpellNumber = Dollars & Cents
End Function
Function SpellNumber2(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = ” Thousand “
Place(3) = ” Million “
Place(4) = ” Billion “
Place(5) = ” Trillion “
‘ String representation of amount.
MyNumber = Trim(Str(MyNumber))
‘ Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, “.”)
‘ Convert cents and set MyNumber to dollar amount.
If DecimalPlace > 0 Then
Cents = Left(Mid(MyNumber, DecimalPlace + 1) & “00”, 2)
MyNumber = Trim(Left(MyNumber, DecimalPlace – 1))
End If
Count = 1
Do While MyNumber <> “”
Temp = GetHundreds(Right(MyNumber, 3))
If Temp <> “” Then Dollars = Temp & Place(Count) & Dollars
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) – 3)
Else
MyNumber = “”
End If
Count = Count + 1
Loop
Select Case Dollars
Case “”
Dollars = “No Bahts”
Case “One”
Dollars = “One Baht”
Case Else
Dollars = Dollars & ” Bahts”
End Select
Select Case Cents
Case “”
Cents = ” Only”
Case “One”
Cents = ” and One “
Case Else
Cents = ” and ” & Cents & “/100”
End Select
SpellNumber2 = Dollars & Cents
End Function
‘ Converts a number from 100-999 into text
Function GetHundreds(ByVal MyNumber)
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right(“000” & MyNumber, 3)
‘ Convert the hundreds place.
If Mid(MyNumber, 1, 1) <> “0” Then
Result = GetDigit(Mid(MyNumber, 1, 1)) & ” Hundred “
End If
‘ Convert the tens and ones place.
If Mid(MyNumber, 2, 1) <> “0” Then
Result = Result & GetTens(Mid(MyNumber, 2))
Else
Result = Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds = Result
End Function
‘ Converts a number from 10 to 99 into text.
Function GetTens(TensText)
Dim Result As String
Result = “” ‘ Null out the temporary function value.
If Val(Left(TensText, 1)) = 1 Then ‘ If value between 10-19…
Select Case Val(TensText)
Case 10: Result = “Ten”
Case 11: Result = “Eleven”
Case 12: Result = “Twelve”
Case 13: Result = “Thirteen”
Case 14: Result = “Fourteen”
Case 15: Result = “Fifteen”
Case 16: Result = “Sixteen”
Case 17: Result = “Seventeen”
Case 18: Result = “Eighteen”
Case 19: Result = “Nineteen”
Case Else
End Select
Else ‘ If value between 20-99…
Select Case Val(Left(TensText, 1))
Case 2: Result = “Twenty “
Case 3: Result = “Thirty “
Case 4: Result = “Forty “
Case 5: Result = “Fifty “
Case 6: Result = “Sixty “
Case 7: Result = “Seventy “
Case 8: Result = “Eighty “
Case 9: Result = “Ninety “
Case Else
End Select
Result = Result & GetDigit _
(Right(TensText, 1)) ‘ Retrieve ones place.
End If
GetTens = Result
End Function
‘ Converts a number from 1 to 9 into text.
Function GetDigit(Digit)
Select Case Val(Digit)
Case 1: GetDigit = “One”
Case 2: GetDigit = “Two”
Case 3: GetDigit = “Three”
Case 4: GetDigit = “Four”
Case 5: GetDigit = “Five”
Case 6: GetDigit = “Six”
Case 7: GetDigit = “Seven”
Case 8: GetDigit = “Eight”
Case 9: GetDigit = “Nine”
Case Else: GetDigit = “”
End Select
End Function
เมื่อวางโค้ดคำสั่งเสร็จแล้วกลับไปที่โปรแกรม Excel ครับ ซึ่งการเรียกใช้งานก็ทำได้ง่าย ๆ เหมือนเรียกใช้ฟังก์ชันอื่น ๆ ทั่วไป โดยโค้ดคำสั่งนี้จะมี 2 ฟังก์ชันให้เลือกใช้งานคือ SpellNumber() และ SpellNumber2()
รูปแบบของฟังก์ SpellNumber() จะเป็นดังนี้
SpellNumber(ตัวเลขที่ต้องแปลง หรือ Cell ที่ต้องการ)
หรือ
SpellNumber2(ตัวเลขที่ต้องแปลง หรือ Cell ที่ต้องการ)
การเรียกใช้คลิกไปที่ Cell ที่ต้องการใส่สูตรแล้วพิมพ์ = SpellNumber(100.50) หรือ = SpellNumber(A1) ซึ่งทั้งสองฟังก์ชันแตกต่างกันตรงที่คำอ่านในส่วนของสตางค์ ดังภาพด่านล่าง
สำหรับบทความการแปลงตัวเลขเป็นตัวอักษรคำอ่านภาษาอังกฤษในโปรแกรม Excel ก็มีเพียงเท่านี้ครับง่าย ๆ ลองเอาไปปรับใช้ในการทำงานดูครับ จะช่วยให้เราทำงานได้ง่ายขึ้น รวดเร็วขึ้น และลดความผิดพลาดจากการพิมพ์เองไปได้เยอะครับ ถ้าบทความนี้มีความผิดพลาดประการใดก็ขออภัยด้วยครับ ถ้าไม่เป็นการรบกวนมากเกินไปก็กระซิบบอกผมก็ได้ครับจะได้แก้ไขให้ถูกต้อง ไว้เจอกันบทความหน้าครับ
[Update] | วิธี เขียน ตัวเลข เป็น ตัวหนังสือ – NATAVIGUIDES
ในบทความนี้จะมาสอนวิธีแปลงจากตัวเลขไปเป็นตัวหนังสือภาษาอังกฤษ โดยใช้ Excel
เนื่องจาก Excel ไม่มีสูตรในการแปลงตัวเลขไปเป็นตัวหนังสือภาษาอังกฤษ (แต่ว่ามีสูตรการตัวเลขไปเป็นตัวหนังสือภาษาไทย นั้นก็คือ BAHTTEXT ) เราจึงจำเป็นต้องใช้การเขียน VBA เข้ามาช่วย
โดยขั้นตอนแรกให้ทำการ เปิด VBA ใน Excel โดยคลิกขวาที่ Sheet แล้วเลือก View Code
แล้วทำการเพิ่ม Module
เอา Code VBA ด้านล่างนี้ใส่เข้าไป แล้วก็ทำการ Save
Option Explicit 'Main Function Function SpellNumber(ByVal MyNumber) Dim Dollars, Cents, Temp Dim DecimalPlace, Count ReDim Place(9) As String Place(2) = " Thousand " Place(3) = " Million " Place(4) = " Billion " Place(5) = " Trillion " ' String representation of amount. MyNumber = Trim(Str(MyNumber)) ' Position of decimal place 0 if none. DecimalPlace = InStr(MyNumber, ".") ' Convert cents and set MyNumber to dollar amount. If DecimalPlace > 0 Then Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _ "00", 2)) MyNumber = Trim(Left(MyNumber, DecimalPlace - 1)) End If Count = 1 Do While MyNumber <> "" Temp = GetHundreds(Right(MyNumber, 3)) If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars If Len(MyNumber) > 3 Then MyNumber = Left(MyNumber, Len(MyNumber) - 3) Else MyNumber = "" End If Count = Count + 1 Loop Select Case Dollars Case "" Dollars = "No Dollars" Case "One" Dollars = "One Dollar" Case Else Dollars = Dollars & " Dollars" End Select Select Case Cents Case "" Cents = " and No Cents" Case "One" Cents = " and One Cent" Case Else Cents = " and " & Cents & " Cents" End Select SpellNumber = Dollars & Cents End Function ' Converts a number from 100-999 into text Function GetHundreds(ByVal MyNumber) Dim Result As String If Val(MyNumber) = 0 Then Exit Function MyNumber = Right("000" & MyNumber, 3) ' Convert the hundreds place. If Mid(MyNumber, 1, 1) <> "0" Then Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred " End If ' Convert the tens and ones place. If Mid(MyNumber, 2, 1) <> "0" Then Result = Result & GetTens(Mid(MyNumber, 2)) Else Result = Result & GetDigit(Mid(MyNumber, 3)) End If GetHundreds = Result End Function ' Converts a number from 10 to 99 into text. Function GetTens(TensText) Dim Result As String Result = "" ' Null out the temporary function value. If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19... Select Case Val(TensText) Case 10: Result = "Ten" Case 11: Result = "Eleven" Case 12: Result = "Twelve" Case 13: Result = "Thirteen" Case 14: Result = "Fourteen" Case 15: Result = "Fifteen" Case 16: Result = "Sixteen" Case 17: Result = "Seventeen" Case 18: Result = "Eighteen" Case 19: Result = "Nineteen" Case Else End Select Else ' If value between 20-99... Select Case Val(Left(TensText, 1)) Case 2: Result = "Twenty " Case 3: Result = "Thirty " Case 4: Result = "Forty " Case 5: Result = "Fifty " Case 6: Result = "Sixty " Case 7: Result = "Seventy " Case 8: Result = "Eighty " Case 9: Result = "Ninety " Case Else End Select Result = Result & GetDigit _ (Right(TensText, 1)) ' Retrieve ones place. End If GetTens = Result End Function ' Converts a number from 1 to 9 into text. Function GetDigit(Digit) Select Case Val(Digit) Case 1: GetDigit = "One" Case 2: GetDigit = "Two" Case 3: GetDigit = "Three" Case 4: GetDigit = "Four" Case 5: GetDigit = "Five" Case 6: GetDigit = "Six" Case 7: GetDigit = "Seven" Case 8: GetDigit = "Eight" Case 9: GetDigit = "Nine" Case Else: GetDigit = "" End Select End Function
ทีนี้เราก็มาลองใช้สูตรโดย พิมพ์ว่า SpellNumber(ตัวเลข) ตัวExcel ก็จะทำการแปลงตัวเลขให้เป็นภาษาอังกฤษแบบอัตโนมัติให้เรา
ส่วนการ Save ไฟล์ Excel ก็จะต้องทำการ Save เป็นไฟล์ .xlsm ด้วยนะเนืองจากเป็นไฟล์ที่มี Code VBA (Excel Macro-Enable Workbook)
การเขียนตัวเลขเป็นตัวหนังสือ
นอกจากการดูบทความนี้แล้ว คุณยังสามารถดูข้อมูลที่เป็นประโยชน์อื่นๆ อีกมากมายที่เราให้ไว้ที่นี่: ดูเพิ่มเติม
คีย์บอร์ดเวลาพิมพ์อักษรเป็นตัวเลข คีย์บอร์ดเพี้ยน
คลิปนี้ทำให้ลูกค้าหรือเพื่อนๆใน youtobe เอาไว้ดูไว้แก้ไข เวลาพิมพ์คีย์บอร์ดกดอักษรเป็นตัวเลขนะครับ
ร้าน มายด์ คอมพิวเตอร์ ห้างเซียร์ รังสิต
โทร.0892252727
ไอดี line 0892252727
ABC kids -Tracing \u0026 Phonics | Learn Alphabet A-Z | ฝึกอ่าน ฝึกเขียน A – Z (ตัวพิมพ์ใหญ่)
ABC kids Tracing \u0026 Phonics | Learn Alphabet AZ | เรียนรู้เกี่ยวกับอักษร A Z ฝึกอ่าน ฝึกเขียน A Z (ตัวพิมพ์ใหญ่)
เรียนรู้เกี่ยวกับอักษร A Z สำหรับเด็กเป็นเกมเพื่อการศึกษาสำหรับเด็ก นอกจากนี้ตัวเกมยังช่วยให้เด็กพัฒนาทักษะพื้นฐาน เช่น ความคิดสร้างสรรค์
Game :ABC Kids Tracing \u0026 Phonics
Download Link:
IOS :https://bit.ly/2YrPlq4
Game : ABC Kids Tracing \u0026 Phonics
Download Link:
Android: https://bit.ly/3kkp198
Ep.1เรียนรู้การเขียนตัวเลข! นับเลขสำหรับเด็ก สนุกไปกับตัวเลข การตูนน่ารักๆ | Game Save the numbers! https://youtu.be/1BzVWN13A44
Ep1. ตัวเลข1,2,3,4 การเรียนรู้สำหรับเด็ก เรียนรู้เกี่ยวกับตัวเลข เรียนรู้การนับเลข เขียนเลข https://youtu.be/9Ch74bb4gAI
Ep.2 ตัวเลข5,6,7,8 การเรียนรู้สำหรับเด็ก เรียนรู้เกี่ยวกับตัวเลข เรียนรู้การนับเลข เขียนเลข https://youtu.be/HWylWBsT_LA
Ep.3 ตัวเลข9,10,11,12 การเรียนรู้สำหรับเด็ก เรียนรู้เกี่ยวกับตัวเลข เรียนรู้การนับเลข เขียนเลข https://youtu.be/faabn2Ksfhc
Ep.4 ตัวเลข13,14,15,16 การเรียนรู้สำหรับเด็ก เรียนรู้เกี่ยวกับตัวเลข เรียนรู้การนับเลข เขียนเลขhttps://youtu.be/ZKPhLDZlKkY
เกมทายเงาสัตว์จากภาพ (9ข้อ) https://youtu.be/CzkLfCLSScs
Ep.1 เกมทายชื่อสัตว์จากภาพ (10ข้อ) https://youtu.be/7OWcyRN_ZUo
Ep.2 เกมทายชื่อสัตว์จากภาพ (10ข้อ) https://youtu.be/XG2Kz6EEjb8
Ep.3 เกมทายชื่อสัตว์จากภาพ (10ข้อ) https://youtu.be/6Y1tMbwmwg8
Ep.4 เกมทายชื่อสัตว์จากภาพ (10ข้อ) https://youtu.be/4dT9GDzZ6mM
Ep.5 เกมทายชื่อสัตว์จากภาพ (10ข้อ) https://youtu.be/Qo0fQ1fIQZY
Ep6 เกมทายชื่อสัตว์จากภาพ (10ข้อ) https://youtu.be/Ld4XTJeHOKw
Ep.7 เกมทายชื่อสัตว์จากภาพ(10ข้อ) https://youtu.be/dlxiqVW0eTM
เกมทายเสียงสัตว์ | เสียงสัตว์อะไร? What animal sound? (10 ข้อ) https://youtu.be/STZ1lZSgxgc
เกม ทายชื่อสัตว์จากภาพ หมวดภาษาอังกฤษ (10ข้อ) https://youtu.be/QrHyoBUkJeM
เกม ทายชื่ออวัยวะในร่างกายจากภาพ หมวดภาษาอังกฤษ (14ข้อ) https://youtu.be/GzjFc7ig4ZY
เกม ตอบปัญหาโควิด19 (10ข้อ) Arthttps://youtu.be/Kvt7zsNZdgg
เกม ทายคำจากภาพ 5 คำ 5พยางค์ จากสุภาพษิต สำนวนไทย 10 ข้อ https://youtu.be/q5ACgDXWbsM
Ep2 เกมทายชื่อจังหวัดจากภาพ 10 ข้อ https://youtu.be/8dVl5BpzTwM เกม
ทายชื่อจังหวัดจากภาพ 10 ข้อ https://youtu.be/UHE3vcuLtk0
เกมทายชื่อประเทศจากภาพ 10 ข้อ https://youtu.be/QhUkJY9wWRU
เกม เก่งคณิตพิชิต วัน เดือนปี | คณิตศาสตร์ระดับประถม 10 ข้อ https://youtu.be/7Up_csm5Of4
[COD210804] การเขียนตัวเลขเป็นตัวหนังสือ by NoTE!!
เขียนตัวเลขเป็นตัวหนังสือ
นอกจากการดูบทความนี้แล้ว คุณยังสามารถดูข้อมูลที่เป็นประโยชน์อื่นๆ อีกมากมายที่เราให้ไว้ที่นี่: ดูวิธีอื่นๆLEARN FOREIGN LANGUAGE
ขอบคุณมากสำหรับการดูหัวข้อโพสต์ วิธี เขียน ตัวเลข เป็น ตัวหนังสือ