首页 > 编程语言 > 详细

我的一些算法

时间:2015-03-31 17:49:02      阅读:235      评论:0      收藏:0      [点我收藏+]
Private Sub Form_Load()
‘newexcel. ----  对象的属性赋值代码

获取磁盘序列号
    Dim file1 As Object
    Dim txt1 As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set d = FSO.getdrive("c:")
    diskcode = Hex(d.SerialNumber)
    Set FSO = CreateObject("Scripting.FileSystemObject")
注册码算法
    If Len(diskcode) > 7 Then
        For i = 1 To 8
            subcode = subcode & Asc(Mid(diskcode, i, 1))
        Next
        regcode = 6 & Mid(subcode * 3, 3, 7)
    Else
        MsgBox ("获取信息失败")
    End If
    
判断注册码文件有没有生成
    Set file1 = CreateObject("scripting.filesystemobject")
    fileadress = "C:\WINDOWS\system32\vovreg.txt"
    If Dir(fileadress, vbDirectory) = "" Then
        MsgBox "您还没有注册过此软件,请您注册,注册码应该是:" & regcode
        getcode = InputBox("请您输入注册码信息", "注册标题", "67258085")
        If getcode = regcode Then
            MsgBox ("注册码正确")
创建注册码文件
            Set txt1 = file1.Createtextfile(fileadress, True)
            txt1.writeline getcode
            txt1.Close
            MsgBox "注册成功"
            Set txt1 = Nothing
            Else: MsgBox ("注册码错误,请重新注册")
        End If
    Else
    End If
End Sub
Private Sub getdisc_Click() 获取磁盘序列号
    Dim file1 As Object
    Dim txt1 As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set d = FSO.getdrive("c:")
    diskcode = Hex(d.SerialNumber)
    MsgBox "磁盘序列号是:" & diskcode
End Sub
Private Sub newexcel_Click() 检查EXECLE有无安装
  Dim objApp As Object
  existenceCheck = True
  
  On Error Resume Next
  Set objApp = CreateObject("Excel.Application")
  
  If Err = 429 Then
     existenceCheck = False
     MsgBox "您没有安装EXCEL,请您安装后再运行软件"
     Else: MsgBox "你的电脑上已经安装EXCEL"
  End If
  
  Set objApp = Nothing
新建EXCEL
    Dim xlApp As Excel.Application Excel对象
    Dim xlBook As Excel.Workbook 工作簿
    Dim xlsheet As Excel.Worksheet 工作表
    Dim xlrange As Excel.Range
    
    Set xlApp = CreateObject("excel.application")
    Set xlBook = xlApp.Workbooks.Add
    xlApp.Visible = True
    xlBook.SaveAs App.Path & "\test.xls"
    MsgBox "新建EXCEL文件成功"

End Sub
Private Sub lookview_Click()

    ExcelFileName = ViewText.Text
    Set xlApp = CreateObject("Excel.Application") 创建EXCEL对象
    xlApp.Visible = True
    Set xlBook = xlApp.Workbooks.Open(ExcelFileName)
 
End Sub

 

我的一些算法

原文:http://www.cnblogs.com/vov5601/p/4381429.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!