6 Replies - 838 Views - Last Post: 09 February 2012 - 10:28 AM Rate Topic: -----

#1 Mike389727  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-February 12

matching information with a predetermined list

Posted 07 February 2012 - 11:24 PM

Public Class Form1

    Dim strname As String
    Dim intage As Integer
    Dim strpass As String


    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub btn1_Click(sender As System.Object, e As System.EventArgs) Handles btn1.Click
        Try


            strname = tb1.Text
            lbl2.Text = strname

            strpass = tb3.Text

            intage = tb2.Text
            lbl3.Text = "age " & intage
        Catch
            MsgBox("please use a number for Age, " & tb2.Text & " is not a number")
        End Try
        If intage < 54 Then
            MsgBox("you are two young")
            Close()


        End If
    End Sub

End Class




Hi, i am new to programming in general but i am having a problem with finding information that i understand currently with my knowledge at the moment.
Any way my problem is this, i am trying to make this program that asks for your name, age and a password the user already has and returns a id number that is generated randomly. my question is how would i match a word to a predetermined list of words then it would get deleted off that said list so it could not be reused. any help would be appreciated. i am stuck in the area of what i should be looking at to solve this problem. my code so far does not have the random number generation yet but i am working on it.

Is This A Good Question/Topic? 0
  • +

Replies To: matching information with a predetermined list

#2 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: matching information with a predetermined list

Posted 07 February 2012 - 11:48 PM

I'm a bit confused on what you're trying to do but to generate random numbers, you can use the random class.
Was This Post Helpful? 0
  • +
  • -

#3 Mike389727  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-February 12

Re: matching information with a predetermined list

Posted 08 February 2012 - 12:11 AM

sorry if im starting to ramble a bit im terrible at explaining. what im trying to do is have a list of words that i can match to a word the user will imput then it will take that word that had been just used off the list of words so it can not be used again. for example when u get a code that you imput to a game while you register that you get when you pay for the game but you cant use that to make lots of accounts with only buying 1 game.
Was This Post Helpful? 0
  • +
  • -

#4 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: matching information with a predetermined list

Posted 08 February 2012 - 12:26 AM

I just have a mind sketch I just came up with. You'll need an Array to store the predetermined words. And after the user input his word, You can use a Loop and a If statement to check against each word you've stored in the array. If a certain word matches a value that's in the array, you can remove it.
Was This Post Helpful? 1
  • +
  • -

#5 Mike389727  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 07-February 12

Re: matching information with a predetermined list

Posted 08 February 2012 - 12:31 AM

Cheers for the help i will look in to that right away and get my program finished.
Was This Post Helpful? 0
  • +
  • -

#6 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1605
  • View blog
  • Posts: 5,162
  • Joined: 25-September 09

Re: matching information with a predetermined list

Posted 08 February 2012 - 05:28 AM

Not sure if this is for a class or anything but if you're just wanting to mess with things like this, I would suggest you look into a List(Of ) collection. It has methods such as .Contains for finding matches and .Remove for removing items.
Was This Post Helpful? 2
  • +
  • -

#7 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: matching information with a predetermined list

Posted 09 February 2012 - 10:28 AM

View PostnK0de, on 08 February 2012 - 12:56 PM, said:

I just have a mind sketch I just came up with. You'll need an Array to store the predetermined words. And after the user input his word, You can use a Loop and a If statement to check against each word you've stored in the array. If a certain word matches a value that's in the array, you can remove it.


I just tried this today and have to correct myself. You need to use ArrayList class. Not Arrays. ArrayList provides functionality to add or remove elements from the collection. (Arrays don't have that) And as CharlieMay has mentioned, using List is a good option too. Both of them looks alike. (maybe I'm wrong on that since I haven't worked with generic collections yet.)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1