转换为char的ascii值 [英] conversion char in its ascii value

查看:61
本文介绍了转换为char的ascii值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hiii ...我是编码领域的新手.....我正在运行一个程序..我必须在其中将字符转换为其Ascii值....我遇到了错误.....
无法将char转换为double"
请帮助我.....

hiii...I am new in the coding world.....I am running a program ..where i have to convert a character in its Ascii value....I am getting anerror.....
"conversion of char in double is not possible"
plz help me ,....

Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tb_from.TextChanged
    Try

        tb_to.Text = tb_from.Text.Substring(0, tb_from.Text.Length - 3) + CStr(CInt(tb_from.Text.Substring(tb_from.Text.Length - 3)) + CInt(ddl_serial.Text))

        If ddl_stat.Text = "NBCC GR" Then
            If tb_from.Text.Substring(0, 1) <> "0" Then
                msgbox.WebMsgBox.Show(" serial should start from '0'")
            Else
                tb_to.Text = tb_from.Text.Substring(0, tb_from.Text.Length - 3) + CStr(CInt(tb_from.Text.Substring(tb_from.Text.Length - 3)) + CInt(ddl_serial.Text))
            End If
        End If

        If ddl_stat.Text = "NBCC Challan" Then
            If tb_from.Text.Substring(0, 1) <> "0" Then
                msgbox.WebMsgBox.Show(" serial should start from '0'")
            Else
                tb_to.Text = tb_from.Text.Substring(0, tb_from.Text.Length - 3) + CStr(CInt(tb_from.Text.Substring(tb_from.Text.Length - 3)) + CInt(ddl_serial.Text))
            End If
        End If

        If ddl_stat.Text = "GR" Or ddl_stat.Text = "GatePass" Or ddl_stat.Text = "Challan" Or ddl_stat.Text = "EB's" Or ddl_stat.Text = "D2D GatePass" Then

            Dim xyz As String

            xyz = tb_from.Text.Substring(0, 1)

            'If tb_from.Text.Substring(0, 1) <> Convert.ToInt32("A") Then

            If xyz <> System.Convert.ToInt32(xyz) Then

                'If xyz <> System.Convert.ToSByte(xyz) Then

                msgbox.WebMsgBox.Show("error")

            End If
            'System.Convert.ToSByte(xyz)
        End If
    Catch ex As Exception
        msgbox.WebMsgBox.Show(ex.ToString())
    End Try
End Sub

推荐答案

不知道所有代码的用途,但是您只需要使用:

Don''t know what all that code is for, but you just use:

Dim i As Integer = Asc("S")



Convert.ToInt32等用于获取包含数字(即"25")的字符串并返回数字表示形式(25).

由LOSMAC添加;)[/EDIT]



The Convert.ToInt32 etc. are using to take a string that contains a number (ie, "25") and returns the numeric representation (25).

Added by LOSMAC ;)[/EDIT]

Dim i As Integer = 0
Dim sString As String = "Hello Word!"

For i = 0 To sString.Length - 1
    MsgBox(sString.Substring(i, 1) & " = " & Asc(sString.Substring(i, 1)), MsgBoxStyle.Information, sString)
Next


这篇关于转换为char的ascii值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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