For Word
Sub Arabic2thai()
For i = 0 To 9
With Selection.Find
.Text = Chr(48+i)
.Replacement.Text = Chr(240+i)
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace := wdReplaceAll
Next
End Sub
Sub Thai2Arabic()
For i = 0 To 9
With Selection.Find
.Text = Chr(240+i)
.Replacement.Text = Chr(48+i)
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace := wdReplaceAll
Next
End Sub
ถ้าใช้ข้างบนแล้วมีปัญหาโดยที่แทนที่ตัวเลข 1234567890 ด้วย ñòóôõö÷øùð ให้ใช้
Sub Arabic2thai()
For i = 0 To 9
With Selection.Find
.Text = Chr(48 + i)
.Replacement.Text = ChrW(3664 + i)
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next
End Sub
Sub Thai2Arabic()
For i = 0 To 9
With Selection.Find
.Text = ChrW(3664 + i)
.Replacement.Text = Chr(48 + i)
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next
End Sub
For Excel
Sub Arabic2Thai()
For i = 0 To 9
Cells.Replace What:=Chr(48 + i), Replacement:=Chr(240 + i)
Next
End Sub
Sub Thai2Arabic()
For i = 0 To 9
Cells.Replace What:=Chr(240 + i), Replacement:=Chr(48 + i)
Next
End Subหรือกำหนดรูปแบบข้อมูลให้เป็น t0 (ตัว T และ เลขศูนย์ 0)