반응형
* VBNET 숫자 (금액) 을 한글로 변화 ...
전체 소스 코드
Form1.vb
Public Class Form1
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
label1.Text = CalToHan(textBox1.Text)
End Sub
Private Function NumberHan(ByVal iTmp As Integer) As String
Dim sTmp As String = ""
Select Case iTmp
Case 0
sTmp = ""
Case 1
sTmp = "일"
Case 2
sTmp = "이"
Case 3
sTmp = "삼"
Case 4
sTmp = "사"
Case 5
sTmp = "오"
Case 6
sTmp = "육"
Case 7
sTmp = "칠"
Case 8
sTmp = "팔"
Case 9
sTmp = "구"
End Select
Return sTmp
End Function
Private Function NumberUnit(ByVal iTmp As Integer) As String
Dim sTmp As String = ""
Select Case iTmp
Case 0
sTmp = ""
Case 1
sTmp = ""
Case 2
sTmp = "십"
Case 3
sTmp = "백"
Case 4
sTmp = "천"
Case 5
sTmp = "만"
Case 6
sTmp = "십"
Case 7
sTmp = "백"
Case 8
sTmp = "천"
Case 9
sTmp = "억"
Case 10
sTmp = "십"
Case 11
sTmp = "백"
Case 12
sTmp = "천"
End Select
Return sTmp
End Function
Private Function CalToHan(ByVal strTmp As String) As String
Dim iTotalLength As Integer = strTmp.Length
Dim iLength As Integer = iTotalLength
Dim cTmp() As Byte = System.Text.Encoding.ASCII.GetBytes(strTmp)
Dim sTmp As String = ""
Dim iCount As Integer
For iCount = 0 To iTotalLength - 1 Step iCount + 1
If cTmp(iCount) - 48 <> 0 Then
sTmp += NumberHan(cTmp(iCount) - 48) + NumberUnit(iLength)
End If
iLength -= 1
Next
sTmp += "원"
Return sTmp
End Function
End Class
*예제 결과
반응형
'VB.NET Programming' 카테고리의 다른 글
[VBNET] 텍스트 파일 읽기 (txt File Read) - 한글 깨짐 방지 (0) | 2020.01.20 |
---|---|
[VBNET] [API] 컨트롤 (Control) 모서리 둥글게 하기 (0) | 2020.01.16 |
[VBNET] IP Ping Check (0) | 2020.01.10 |
[VBNET] 구조체 를 바이트 배열로 또는 바이트 배열을 구조체로 변환 (0) | 2020.01.09 |
[VBNET] [API] PC (종료, 재시작)또는 Diagnostics.Process 이용 PC 종료 (0) | 2020.01.06 |