Microsoft Small Basic

Program Listing:
Embed this in your website
' Chinese Numerals (漢数字)
' Version 0.1b
' Copyright © 2018 Nonki Takahashi. The MIT License.

GraphicsWindow.Title = "Chinese Numerals 0.1b"
d = "一二三四五六七八九"
k = "十百千"
k10 = "万億兆京垓𥝱穣"
Form()
While "True"
  If buttonClicked Then
    arabic = Controls.GetTextBoxText(num)
    Convert()
    Shapes.SetText(knum, kanji)
    buttonClicked = "False"
  Else
    Program.Delay(100)
  EndIf
EndWhile

Sub Convert
  arabic = Math.Floor(arabic)
  len = Text.GetLength(arabic)
  r4 = Math.Remainder(len - 1, 4)   ' for k
  i4 = Math.Floor((len - 1) / 4)    ' for k10
  kanji = ""
  k4 = ""
  For p = 1 To len
    k1 = Text.GetSubText(d, Text.GetSubText(arabic, p, 1), 1)
    k4 = k4 + k1
    If 0 < r4 Then
      If k1 <> "" Then
        k4 = k4 + Text.GetSubText(k, r4, 1)
      EndIf
    ElseIf 0 < i4 Then
      If k4 <> "" Then
        k4 = k4 + Text.GetSubText(k10, i4, 1)
        kanji = kanji + k4
        k4 = ""
      EndIf
      i4 = i4 - 1
    EndIf
    r4 = r4 - 1
    If r4 < 0 Then
      r4 = r4 + 4
    EndIf
  EndFor
  If k4 <> "" Then
    kanji = kanji + k4
  EndIf
EndSub

Sub Form
  GraphicsWindow.FontName = "Segoe UI"
  GraphicsWindow.BrushColor = "Black"
  GraphicsWindow.DrawText(10, 10, "Number")
  num = Controls.AddTextBox(70, 7)
  Controls.AddButton("OK", 240, 5)
  GraphicsWindow.FontSize = 20
  knum = Shapes.AddText("〇")
  Shapes.Move(knum, 10, 40)
  Controls.ButtonClicked = OnButtonClicked
EndSub

Sub OnButtonClicked
  buttonClicked = "True"
EndSub

Copyright (c) Microsoft Corporation. All rights reserved.