Danh mục

Programming Microsoft SQL Server 2000 with Microsoft Visual Basic .Net - P6

Số trang: 50      Loại file: pdf      Dung lượng: 0.00 B      Lượt xem: 9      Lượt tải: 0    
tailieu_vip

Hỗ trợ phí lưu trữ khi tải xuống: 6,000 VND Tải xuống file đầy đủ (50 trang) 0
Xem trước 5 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Tham khảo tài liệu programming microsoft sql server 2000 with microsoft visual basic .net - p6, công nghệ thông tin, cơ sở dữ liệu phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả
Nội dung trích xuất từ tài liệu:
Programming Microsoft SQL Server 2000 with Microsoft Visual Basic .Net - P6 End Sub Going from a hexadecim al value t o a Long value is m or e com plicat ed for a couple of reasons. First , t her e is no built - in funct ion. Second, hexadecim al num bers need t o be convert ed on a charact er - by - charact er basis t hat reflect s t he char act er’s posit ion in t he hexadecim al num ber. This t ask is furt her com plicat ed by t hat fact t hat charact ers go out side t he decim al range of 0 t hrough 9 t o t he hex adecim al range of 0 t hrough F. The follow ing sam ple per for m s a check t o v er ify t hat t he hexadecim al st r ing value doesn’t exceed t he m axim um Long value. The hex represent at ion for t he m axim um Long value is 7FFFFFFFFFFFFFFF. Aft er perform ing a bound check for t he m ax im um hex adecim al value, t he Convert Hex ToLng pr ocedur e st art s a loop t hat it erat es t hr ough successiv e charact ers in t he hexadecim al num ber. St art ing at t he far r ight charact er , t he loop evaluat es each charact er. The evaluat ion m ult iplies t he hex charact er’s decim al v alue by a power of 16. The pow ers range in value fr om 0 for t he far right charact er t o up t o 15 for t he sixt eent h hex charact er ( if t her e is one) . When t he Conv ert HexToLng procedur e finishes looping t hr ough t he charact er s in t he hexadecim al num ber, t he pr ocedur e present s a m essage box w it h t he decim al value of t he hexadecim al num ber in Text Box1. Private Sub Button4_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button4.Click ’Call program to convert a hexadecimal number to ’a Long number. ConvertHexToLng() End Sub Sub ConvertHexToLng() ’Assign TextBox1 contents to hexStr. ’Dim strValue As String = TextBox1.Text Dim hexStr As String = TextBox1.Text ’If hexStr greater than 7FFFFFFFFFFFFFFF, then abort. Dim hexchars As Integer = Len(hexStr) If (hexchars = 16 And hexStr.Chars(0) > “7”) Or _ hexchars > 16 Then MsgBox(“Hex values beyond 7FFFFFFFFFFFFFFF “ & _ “generate an exception. Enter a smaller “ & _ “hex value.”) Exit Sub End If ’Variable lnghexstr stores long of hex string in TextBox1, ’and i is a loop counter value. Dim lnghexstr As Long Dim i As Integer ’Loop through characters to compute decimal equivalent ’of hex string. lnghexstr = 0 For i = 0 To hexchars - 1 Select Case Mid(UCase(hexStr), hexchars - i, 1) Case “0 lnghexstr += CLng(0 * (16 ^ i)) Case “1 lnghexstr += CLng(1 * (16 ^ i)) Case “2 lnghexstr += CLng(2 * (16 ^ i)) Case “3Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. lnghexstr += CLng(3 * (16 ^ i)) Case “4 lnghexstr += CLng(4 * (16 ^ i)) Case “5 lnghexstr += CLng(5 * (16 ^ i)) Case “6 lnghexstr += CLng(6 * (16 ^ i)) Case “7 lnghexstr += CLng(7 * (16 ^ i)) Case “8 lnghexstr += CLng(8 * (16 ^ i)) Case “9 lnghexstr += CLng(9 * (16 ^ i)) Case “A lnghexstr += CLng(10 * (16 ^ i)) Case “B lnghexstr += CLng(11 * (16 ^ i)) Case “C lnghexstr += CLng(12 * (16 ^ i)) Case “D ...

Tài liệu được xem nhiều: