zoukankan      html  css  js  c++  java
  • VB 计算34进制转换

     Dim X34 As String ="0123456789ABCDEFGHJKLMNPQRSTUVWXYZ" '34进制,去除I和O
    
      Private Function CovvertTo34(ByVal val As Integer) As String
            Dim Result As String = String.Empty
            While val >= 34
                Result = X34(val Mod 34) + Result
                val = Int(val / 34)
            End While
            If val >= 0 Then
                Result = X34(val) + Result
            End If
            Return Result
        End Function
    
       Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Label1.Text = Microsoft.VisualBasic.Right("0000" & CovvertTo34(NumericUpDown1.Value), 4)
            Label2.Text = Microsoft.VisualBasic.Right("0000" & CovvertTo34(NumericUpDown1.Value + 1), 4)
        End Sub

    第二种方法:

     Private Function Tnsfer34(ByVal xInt As Integer) As String
    
            Dim xMap24 As String = "ABCDEFGHJKLMN"
            Dim xMap34 As String = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
    
            Dim xRetDigit34 As String = ""
    
            Dim xxInt As Integer = (xInt Mod 39304)
            Dim xHead24Int As Integer = Int(xInt / 39304)   ' A-Z , 不含 I & O
            Dim xRetDigit24 As String = Microsoft.VisualBasic.Left(xMap24(xHead24Int), 1)
    
            While xxInt > 0
                xRetDigit34 = Mid(xMap34, (xxInt Mod 34) + 1, 1) & xRetDigit34
                xxInt = Int(xxInt / 34)
            End While
    
            Return xRetDigit24 & Microsoft.VisualBasic.Right(Replace(Space(3), " ", "0") & xRetDigit34, 3)
    
        End Function
    
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            Label2.Text = Tnsfer34(NumericUpDown1.Value)
    
        End Sub

    本文来自博客园,作者:云辰,转载请注明原文链接:https://www.cnblogs.com/yunchen/p/12095748.html

  • 相关阅读:
    bzoj 1497 最小割模型
    bzoj 1024 暴力深搜
    POJ1163(简单的DP)
    POJ3287(BFS水题)
    N皇后问题(DFS)
    BFS求解迷宫的最短路径问题
    poj2386(简单的dfs/bfs)
    Fence Repair(poj3253)
    Best cow Line(POJ 3617)
    全排列
  • 原文地址:https://www.cnblogs.com/yunchen/p/12095748.html
Copyright © 2011-2022 走看看