All pastes #249750 Raw Edit

WordGen .NET

public text v1 · immutable
#249750 ·published 2006-11-16 02:52 UTC
rendered paste body
Imports System.IO

Public Class Form1
    Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents txtWord As System.Windows.Forms.TextBox
    Friend WithEvents btnGen As System.Windows.Forms.Button
    Friend WithEvents btnExit As System.Windows.Forms.Button
    Friend WithEvents lbxWords As System.Windows.Forms.ListBox
    Friend WithEvents lblCount As System.Windows.Forms.Label
    Friend WithEvents lstContext As System.Windows.Forms.ContextMenu
    Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.txtWord = New System.Windows.Forms.TextBox
        Me.btnGen = New System.Windows.Forms.Button
        Me.btnExit = New System.Windows.Forms.Button
        Me.lbxWords = New System.Windows.Forms.ListBox
        Me.lblCount = New System.Windows.Forms.Label
        Me.lstContext = New System.Windows.Forms.ContextMenu
        Me.MenuItem1 = New System.Windows.Forms.MenuItem
        Me.MenuItem2 = New System.Windows.Forms.MenuItem
        Me.SuspendLayout()
        '
        'txtWord
        '
        Me.txtWord.Location = New System.Drawing.Point(8, 8)
        Me.txtWord.Name = "txtWord"
        Me.txtWord.Size = New System.Drawing.Size(312, 20)
        Me.txtWord.TabIndex = 1
        Me.txtWord.Text = ""
        '
        'btnGen
        '
        Me.btnGen.Location = New System.Drawing.Point(8, 32)
        Me.btnGen.Name = "btnGen"
        Me.btnGen.TabIndex = 2
        Me.btnGen.Text = "Generate"
        '
        'btnExit
        '
        Me.btnExit.Location = New System.Drawing.Point(88, 32)
        Me.btnExit.Name = "btnExit"
        Me.btnExit.TabIndex = 3
        Me.btnExit.Text = "Exit"
        '
        'lbxWords
        '
        Me.lbxWords.ContextMenu = Me.lstContext
        Me.lbxWords.Location = New System.Drawing.Point(8, 64)
        Me.lbxWords.Name = "lbxWords"
        Me.lbxWords.Size = New System.Drawing.Size(312, 355)
        Me.lbxWords.TabIndex = 4
        '
        'lblCount
        '
        Me.lblCount.Location = New System.Drawing.Point(176, 32)
        Me.lblCount.Name = "lblCount"
        Me.lblCount.Size = New System.Drawing.Size(136, 24)
        Me.lblCount.TabIndex = 5
        Me.lblCount.Text = "Count:"
        '
        'lstContext
        '
        Me.lstContext.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1, Me.MenuItem2})
        '
        'MenuItem1
        '
        Me.MenuItem1.Index = 0
        Me.MenuItem1.Text = "Remove"
        '
        'MenuItem2
        '
        Me.MenuItem2.Index = 1
        Me.MenuItem2.Text = "Copy"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(336, 430)
        Me.Controls.Add(Me.lblCount)
        Me.Controls.Add(Me.lbxWords)
        Me.Controls.Add(Me.btnExit)
        Me.Controls.Add(Me.btnGen)
        Me.Controls.Add(Me.txtWord)
        Me.Name = "Form1"
        Me.Text = "WordGen"
        Me.ResumeLayout(False)

    End Sub

#End Region
    Dim streamRead As StreamReader
    Dim streamWrite As StreamWriter

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()

    End Sub
    Private Function CheckWord(ByVal a As String) As Boolean
        Dim chrTextBox() As Char = Me.txtWord.Text.ToLower.ToCharArray
        Dim chrLetters() As Char = a.ToCharArray
        Dim counter As Integer
        Dim counter2 As Integer
        Dim blnTest As Boolean
        For counter = 0 To (chrLetters.Length - 1)
            If CheckLetter(chrLetters(counter), chrTextBox) = False Then
                blnTest = False
                Exit For
            Else
                blnTest = True
            End If
        Next
        Return blnTest

    End Function
    Private Function CheckLetter(ByVal b As String, ByVal c As Array) As Boolean
        Dim counter3 As Integer
        For counter3 = 0 To (c.Length - 1)
            If b = c(counter3) Then
                c(counter3) = Nothing
                Return True
            End If
        Next
        Return False
    End Function

    Private Sub btnGen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGen.Click
        Dim strDicWord As String
        Dim counter As Integer
        Dim counter2 As Integer = 0
        lbxWords.Items.Clear()
        btnGen.Enabled = False
        Me.Text = "WordGen     ......finding words"
        streamRead = File.OpenText("WORD.LST")
        For counter = 1 To 173528
            strDicWord = streamRead.ReadLine
            If CheckWord(strDicWord) Then
                counter2 = counter2 + 1
                lbxWords.Items.Add(strDicWord)
                streamWrite = File.AppendText("mylist.txt")
                streamWrite.WriteLine(strDicWord)
                streamWrite.Close()
            End If
            lblCount.Text = "Count: " + counter2.ToString + " words!"
        Next
        streamRead.Close()
        btnGen.Enabled = True
        Me.Text = "WordGen"
    End Sub


    Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
        lbxWords.Items.Remove(lbxWords.SelectedItem)

    End Sub

    Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
        Clipboard.SetDataObject(lbxWords.SelectedItem)

    End Sub
End Class