Private Sub Text2_Change() '大寫(xiě)金額轉(zhuǎn)換成阿拉伯?dāng)?shù)字金額
創(chuàng)新互聯(lián)公司自成立以來(lái),一直致力于為企業(yè)提供從網(wǎng)站策劃、網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、成都做網(wǎng)站、電子商務(wù)、網(wǎng)站推廣、網(wǎng)站優(yōu)化到為企業(yè)提供個(gè)性化軟件開(kāi)發(fā)等基于互聯(lián)網(wǎng)的全面整合營(yíng)銷服務(wù)。公司擁有豐富的網(wǎng)站建設(shè)和互聯(lián)網(wǎng)應(yīng)用系統(tǒng)開(kāi)發(fā)管理經(jīng)驗(yàn)、成熟的應(yīng)用系統(tǒng)解決方案、優(yōu)秀的網(wǎng)站開(kāi)發(fā)工程師團(tuán)隊(duì)及專業(yè)的網(wǎng)站設(shè)計(jì)師團(tuán)隊(duì)。
Dim i As Integer
Dim j As Integer
Dim myint As Integer
Dim myint1 As Integer
Dim mydoub As Double
Dim mystr As String
Dim mystr1 As String
Dim mystr2 As String
Dim mystr3 As String
Dim mystr4 As String
Dim money As Long
Dim money1 As Integer
Dim money2 As Long
mystr = Text2.Text
myint = InStr(mystr, ".")
If myint = 0 Then
mystr = Text2.Text
Else
mystr3 = Right(Text2.Text, Len(Text2.Text) - myint)
If mystr3 "" Then '轉(zhuǎn)換小數(shù)位
mystr4 = Left(mystr3, 1)
mystr3 = Right(mystr3, Len(mystr3) - 1)
If mystr4 "0" Then
mystr2 = mystr2 + setdata(Val(mystr4)) + "角"
End If
If mystr3 "" Then
mystr4 = Left(mystr3, 1)
mystr2 = mystr2 + setdata(Val(mystr4)) + "分"
End If
End If
mystr = Left(Text2.Text, myint - 1)
End If
j = Len(mystr)
For i = 1 To Len(mystr) '轉(zhuǎn)換整數(shù)位
money2 = Left(mystr, i)
money1 = Right(money2, 1)
If money1 = 0 Then
If j = 5 Then
If Right(mystr1, 1) "萬(wàn)" Then mystr1 = mystr1 "萬(wàn)"
Else
If Right(mystr1, 1) "零" And Right(money, j) 0 Then mystr1 = mystr1 "零"
End If
Else
mystr1 = mystr1 setdata(money1) + chang(j)
End If
j = j - 1
Next i
Text1.Text = mystr1 "元" mystr2 '顯示大寫(xiě)
End Sub
Private Function Conver_Hex(ByVal L As Long) As Array
Dim str_L As String = Hex(L)
If str_L.Length \ 2 0 Then
str_L = "0" str_L
End If
Dim byt(str_L.Length / 2 - 1) As Byte
For i = 0 To str_L.Length / 2 - 1
byt(i) = Convert.ToByte(str_L.Substring(2 * i, 2), 16)
Next
Return byt
End Function
'下面是調(diào)用代碼
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim L As Double = 123456
Dim byt() As Byte = Conver_Hex(L)
End Sub
最簡(jiǎn)單的就是直接轉(zhuǎn)換,就是把字符串變量賦值給數(shù)值變量。\x0d\x0a數(shù)值變量=字符串\x0d\x0a\x0d\x0a如果必須轉(zhuǎn)換,就使用 Val 函數(shù)賦值,會(huì)把字符串轉(zhuǎn)換成雙精度數(shù)。\x0d\x0a比如:數(shù)值變量=Val(字符串)\x0d\x0a例:\x0d\x0an = Val("3.5") ' 變量n賦值為3.5\x0d\x0a\x0d\x0a或者使用取整函數(shù),也可以轉(zhuǎn)換。\x0d\x0a比如:數(shù)值變量=Int(字符串) 或者 數(shù)值變量=CInt(字符串)\x0d\x0a例:\x0d\x0an = Int("3.5") ' 取整數(shù),變量n賦值為3\x0d\x0a\x0d\x0an = CInt("3.5") ' 四舍五入取整數(shù),變量n賦值為4
Dim byts1() As Byte = {255, 255, 0, 0}
'4位16進(jìn)制數(shù)組轉(zhuǎn)Integer
Dim value As Integer = BitConverter.ToInt32(byts1, 0)
'Integer轉(zhuǎn)4位16進(jìn)制數(shù)組()
Dim byts2() As Byte = BitConverter.GetBytes(value)
string?str1?=?"a=1.2,3.5,7.88";
var?arr?=?(from?s?in?str1.Split('=')[1].Split(',')?where?s.Trim()?!=?""?select?Convert.ToDouble(s)).ToArray();
Split(',')這個(gè)地方逗號(hào)是全角還是半角的按照你文本內(nèi)容里面的來(lái)
明白你的意思了,只要是字母都會(huì)轉(zhuǎn)換成數(shù)字,幫你寫(xiě)好了("usernane"和 "pasward" 我這里寫(xiě)成 "username" 和" password")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim username, password As String
Dim temp As Long
Dim r As String = ""
Dim v As String = TextBox1.Text
For Each c In v.ToString
If IsNumeric(c) Then
r = c
Else
r = ((Asc(c) - 65).ToString("00"))
End If
Next
username = r
temp = username * 3 - 500
password = CStr(temp)
TextBox2.Text = password
End Sub