Sei sulla pagina 1di 3

Imports System.IO Imports System.Runtime.CompilerServices Imports System.Windows.Forms Imports System.Drawing Imports System.Diagnostics Imports System.ComponentModel Imports System.

Collections Imports System Imports Microsoft.VisualBasic.CompilerServices Imports Microsoft.VisualBasic Namespace VelezCorpIISPro Public Class NUMERKEYGEN Inherits Form Private Sub InitializeComponent() Me.NumberKey = New System.Windows.Forms.Button() Me.Button2 = New System.Windows.Forms.Button() Me.ListBox1 = New System.Windows.Forms.ListBox() Me.SuspendLayout() ' 'NumberKey ' Me.NumberKey.Location = New System.Drawing.Point(460, 15) Me.NumberKey.Name = "NumberKey" Me.NumberKey.Size = New System.Drawing.Size(139, 30) Me.NumberKey.TabIndex = 0 Me.NumberKey.Text = "Numberkey" Me.NumberKey.UseVisualStyleBackColor = True ' 'Button2 ' Me.Button2.Location = New System.Drawing.Point(460, 334) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(139, 30) Me.Button2.TabIndex = 1 Me.Button2.Text = "Close App." Me.Button2.UseVisualStyleBackColor = True ' 'ListBox1 ' Me.ListBox1.FormattingEnabled = True

Me.ListBox1.Location = New System.Drawing.Point(29, 9) Me.ListBox1.Name = "ListBox1" Me.ListBox1.Size = New System.Drawing.Size(425, 355) Me.ListBox1.TabIndex = 2 ' 'NUMERKEYGEN ' Me.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink Me.ClientSize = New System.Drawing.Size(611, 383) Me.Controls.Add(Me.ListBox1) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.NumberKey) Me.Name = "NUMERKEYGEN" Me.ResumeLayout(False) End Sub #Region "Variables del Sistema" Dim File As Double Dim Fread As Double Dim leter As String Dim cadef As String Dim cade As String Public Vkey() As String Dim m_Excel As Microsoft.Office.Interop.Excel.Application #End Region Public Sub New() Me.InitializeComponent() End Sub Friend WithEvents NumberKey As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ProjectData.EndApp() End Sub Private Sub NumberKey_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumberKey.Click Dim Dim Dim Dim Dim Try minimo As Double = 1 maximo As Double = 10000 min As Double = 65 max As Double = 90 NumerAle As String

cade = "" Vkey(0) = "" Catch exception1 As Exception End Try Dim ValRed As Double = maximo + 1 ReDim Vkey(ValRed) For i = 0 To ValRed line1: Randomize() ' inicializar la semilla For n = 0 To 2 leter = ((min - max) * Rnd() + max) cade = cade & Chr(leter) Next n cadef = cade NumerAle = "V" & cadef & "E " & cadef & "L" & Format(CLng((minimo - maximo) * Rnd() + maximo), "00000") & "FSCT" & _

Format(CLng((minimo - maximo) * Rnd() + maximo), "00000") & "" & _ Format(CLng((minimo - maximo) * Rnd() + maximo), "00000") & "IISPRO" & _ "J" & cadef & "A" & cadef & "V" & cadef & Format(CLng((minimo - maximo) * Rnd() + maximo), "0000") For j = 0 To ValRed '(Strings.StrComp(str, Conversions.ToString(obj5), CompareMethod.Binary) = 0) If (Strings.StrComp(Vkey(j), Conversions.ToString(NumerAle), CompareMethod.Text) <> 0) Then 'If Vkey(j) <> NumerAle Then GoTo Line2 Else GoTo Line1 End If line2: Next j Vkey(i) = NumerAle cade = "" Next i m_Excel = CreateObject("Excel.Application") Try m_Excel.Workbooks.Open("X:\BasedeDatos.xlsx", Password:="velez&corp") m_Excel.Visible = False m_Excel.ActiveWorkbook.ChangeFileAccess(Microsoft.Office.Interop.Excel.XlFileAccess.xlReadWrit e, "", "") Catch exception2 As Exception End Try Dim cont As Long Dim valcel As String 'Contador Fread = 2 For cont = 0 To 10000 valcel = m_Excel.Worksheets("REGISTRO").Cells(Fread, 4).Value If valcel = "" Then Exit For End If Fread = Fread + 1 Next cont 'Stop File = cont + 2 For k = 0 To ValRed 'Stop ListBox1.Items.Add(Vkey(k)) m_Excel.Worksheets("REGISTRO").Cells(File, 3).Value = Vkey(k) File = File + 1 Next k m_Excel.Application.ActiveWorkbook.Save() If Not m_Excel Is Nothing Then m_Excel.Quit() m_Excel = Nothing End If ProjectData.EndApp() End Sub Friend WithEvents ListBox1 As System.Windows.Forms.ListBox End Class End Namespace

Potrebbero piacerti anche