字符串反转vb.net 字符串反转输出java
VB.NET中如何将一个转化为字符串,并取它的每一个字符
VB.NET 整型 i 转化为字符串 s , 字符串 s 转化为字符数组 CharArr :
成都创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站建设、做网站、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的化州网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
Dim i As Integer = 12345
Dim s As String
Dim CharArr As Char()
s = i.ToString()
CharArr = s.ToCharArray()
将 CharArr 数组反转:
Array.Reverse(CharArr)
gb2312>unicode>utf8, 以及逆转的方法'>VB.net 字符转换问题 字符(汉字、数字、字母、符号)>gb2312>unicode>utf8, 以及逆转的方法
字符编码转换吗?
1.字符与gb2312(gbk的子集):
Public Function GBKEncode(ByVal sInput As String) As String
Dim ret_GBKEncode As String = ""
Dim i As Integer
Dim startIndex As Integer = 0
Dim endIndex As Integer
Dim x() As Byte = System.Text.Encoding.Default.GetBytes(sInput) '字符以及字符串在vb2008中都是以unicode编码存储的
endIndex = x.Length - 1
For i = startIndex To endIndex
ret_GBKEncode = "%" Hex(x(i))
Next
Return ret_GBKEncode
End Function
'GBK解码
Public Function GBKDecode(ByVal sInput As String) As String
sInput = sInput.Replace("%", "")
Dim ret_GBKDecode As String = ""
Dim sLen As Integer = sInput.Length
Dim n As Integer = sLen \ 2
Dim sBytes(0 To n - 1) As Byte
'转化为字节码
For i As Integer = 1 To n
sBytes(i - 1) = CByte("H" sInput.Substring(2 * i - 2, 2))
Next
'将字节码转化为字符串
ret_GBKDecode = System.Text.Encoding.Default.GetString(sBytes)
Return ret_GBKDecode
End Function
2.Unicode字符串为UTF-8
Imports System.Text
Public Function StringAsUtf8Bytes(ByVal strData As String) As Byte()
Dim bytes() As Byte
bytes = Encoding.UTF8.GetBytes(strData)
Return bytes
End Function
'这里可以类推出好几种。
用VB6.0写字符串反转的程序
REM 这是VB.NET写的函数 VB6应该也是一样的
Function StrReverse(ByVal str As String)
Dim str2 As String = ""
Dim cs As Char() = str.ToCharArray()
For i As Integer = cs.Length - 1 To 0 Step -1
str2 = str2 + cs(i)
Next
Return str2
End Function
VB.NET中字符串倒序的问题
好象有个StrReverse函数是直接反转字符串的吧..
我平时用的是VB6.但是.NET中应该也是可以用MID的
你注意看FOR 是从len-1到0的..而mid中是不允许出现0的..
你看看MID运行不了时,是不是返回I是0的时间
改成:
For i = Len(sstr) To 1 Step -1
试试了?
文章题目:字符串反转vb.net 字符串反转输出java
地址分享:http://myzitong.com/article/dodophj.html