二进制转八进制vb6程序

来源:互联网 发布:手机网络正常微信不能 编辑:程序博客网 时间:2024/05/19 02:42

【原】二进制转八进制vb6程序

Private Sub Command1_Click()
  Dim strN As String, strOct As String, strBin(), iOct As String
  Dim intXh As Integer, i As Integer, j As Integer, strTmp As String
  
  strBin = Array("000", "001", "010", "011", _
                 "100", "101", "110", "111")
  
  strN = InputBox("", "", "111000111")
  
  If Len(strN) Mod 3 <> 0 Then strN = String(3 - Len(strN) Mod 3, "0") & strN
  
  intXh = Len(strN) \ 3
  For i = 1 To intXh
      strTmp = Right(strN, 3)
      For j = 0 To 7
          If strTmp = strBin(j) Then
             iOct = j & iOct
             Exit For
          End If
      Next
      strN = Left(strN, Len(strN) - 3)
  Next
  
  MsgBox "O" & iOct
                             
End Sub

0 0
原创粉丝点击