整数到字符串 [英] Integer to String

查看:96
本文介绍了整数到字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有两个文本字段,在第一个字段中,当我键入1(数字)时,必须在第二个字段中将其转换为一个(字符串),依此类推.怎么办.


i have two text fields, in the first fields when i type 1(digits) and it must convert to one(string) in the second field and so on. how to do.
thanks in advance.

推荐答案

使用单词一个",两个"等的列表或数组,并使用数字将其索引到列表中.
Use a list or array of the words "one", "two", etc and use the number to index into the list. Basic programming really.


您的表单上有两个名为TextBox1和Textbox2的文本框;

With 2 textboxes on your form named TextBox1 and Textbox2;

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    Dim stringArray() As String = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}

    Dim inputNumber As Integer = 0
    Dim outputString As String = String.Empty

    If IsNumeric(TextBox1.Text) Then
        For Each item As String In TextBox1.Text.ToCharArray
            inputNumber = CInt(item)

            outputString = outputString + stringArray(inputNumber)
        Next
    End If
    TextBox2.Text = outputString
End Sub


这篇关于整数到字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆