Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.76 KB | None | 0 0
  1. Public Class Form1
  2.     Private Function getMax()
  3.         On Error GoTo getMax_Error
  4.         getMax = TextBox2.Text - 1
  5.         Exit Function
  6.  
  7. getMax_Error:
  8.         MsgBox("Bitte eine Zahl eingeben!")
  9.     End Function
  10.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  11.         TextBox1.Clear()
  12.         Dim Rnd As New Random
  13.         For i As Integer = 0 To (getMax())
  14.             TextBox1.Text &= Chr(65 + Rnd.Next(0, 9))
  15.         Next
  16.     End Sub
  17.  
  18.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  19.         TextBox1.Clear()
  20.         Dim Rnd As New Random
  21.         For i As Integer = 0 To (getMax())
  22.             TextBox1.Text &= Rnd.Next(0, 9)
  23.         Next
  24.     End Sub
  25.  
  26.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  27.         TextBox1.Clear()
  28.         Dim Rnd As New Random
  29.         For i As Integer = 0 To (getMax())
  30.             If Rnd.Next(-5, 5) > 0 Then
  31.                 TextBox1.Text &= Chr(65 + Rnd.Next(0, 9))
  32.             Else
  33.                 TextBox1.Text &= Rnd.Next(0, 9)
  34.             End If
  35.         Next
  36.     End Sub
  37.  
  38.     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  39.         If ComboBox1.Text = "Buchstabe" Then
  40.             TextBox1.Clear()
  41.             Dim Rnd As New Random
  42.             For i As Integer = 0 To (getMax())
  43.                 If Gerade(i) Then
  44.                     TextBox1.Text &= Chr(Vokale()(Rnd.Next(0, 4)))
  45.                 Else
  46.                     TextBox1.Text &= Chr(Konsonanten()(Rnd.Next(0, 20)))
  47.  
  48.                 End If
  49.  
  50.             Next
  51.         ElseIf ComboBox1.Text = "Zahl" Then
  52.             TextBox1.Clear()
  53.             Dim Rnd As New Random
  54.             For i As Integer = 0 To (getMax())
  55.                 TextBox1.Text &= Rnd.Next(0, 9)
  56.             Next
  57.         ElseIf ComboBox1.Text = "Gemischt" Then
  58.             TextBox1.Clear()
  59.             Dim Rnd As New Random
  60.             For i As Integer = 0 To (getMax())
  61.                 If Rnd.Next(-300, 300) > 0 Then
  62.                     TextBox1.Text &= Chr(97 + Rnd.Next(0, 25))
  63.                 Else
  64.                     TextBox1.Text &= Rnd.Next(0, 9)
  65.                 End If
  66.             Next
  67.         ElseIf ComboBox1.Text = "Produktkey-Style" Then
  68.             TextBox1.Clear()
  69.             Dim Rnd As New Random
  70.             For i As Integer = 0 To 15
  71.                 If i = 4 Or i = 8 Or i = 12 Then
  72.                     TextBox1.Text &= "-"
  73.                 End If
  74.                 TextBox1.Text &= Rnd.Next(0, 9)
  75.             Next
  76.         End If
  77.     End Sub
  78.     Function Vokale()
  79.         Dim arr_vok As Integer() = New Integer(4) {97, 101, 105, 111, 117}
  80.         Vokale = arr_vok
  81.  
  82.     End Function
  83.     Function Konsonanten()
  84.         Dim arr_kon As Integer() = New Integer(20) {98, 99, 100, 102, 103, 104, 106, 107, 108, 109, 110, 112, 113, 114, 115, 116, 118, 119, 120, 121, 122}
  85.         Konsonanten = arr_kon
  86.     End Function
  87.     Function Gerade(ByVal zahl As Integer)
  88.         Gerade = (zahl Mod 2) = 0
  89.     End Function
  90.  
  91.  
  92.     Private Sub ComboBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
  93.         If ComboBox1.Text = "Produktkey-Style" Then
  94.             Label1.Hide()
  95.             TextBox2.Hide()
  96.             Label4.Show()
  97.         Else
  98.             Label1.Show()
  99.             TextBox2.Show()
  100.             Label4.Hide()
  101.         End If
  102.     End Sub
  103.  
  104.     Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
  105.  
  106.     End Sub
  107.  
  108.     Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
  109.  
  110.     End Sub
  111. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement