6 Replies - 544 Views - Last Post: 01 February 2012 - 01:14 AM Rate Topic: -----

#1 BigdWiki  Icon User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 14
  • Joined: 22-November 11

Searching an array

Posted 31 January 2012 - 02:34 PM

Here is my problem:

Write a program that requests a color as input in a text box and then determines whether or not the color is in the text file. The program should use the Boolean-valued Function procedure IsCrayola that returns the value True if the color in the text box is a Crayola color.

Here is my code:
Public Class Form1
    Dim colors() As String = IO.File.ReadAllLines("colors.txt")
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text = "" Then MessageBox.Show("No color!") 'Input validation!
        If IsCrayola() = 1 Then MessageBox.Show("Color Found") Else MessageBox.Show("Not Found")
    End Sub
    Function IsCrayola(ByVal colors As String) As Boolean
        Dim FindString As String = TextBox1.Text
        For Each Str As String In colors
            If Str.Contains(FindString) Then
                Return CBool(1)
            End If
        Next
    End Function
End Class



What am I missing? Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Searching an array

#2 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5316
  • View blog
  • Posts: 11,374
  • Joined: 02-June 10

Re: Searching an array

Posted 31 January 2012 - 02:53 PM

Who says you're missing anything? Are you having errors or crashes?


Reminder to new folks: This is homework and we don't provide completed code for homework. Rather we try to help the student comprehend the concept they are struggling with so they can write their own code. They are being graded on their skill not ours.

This is the 'Help me with my homework' article you wanted.
Stages of asking for homework help on a forum.
I don't want you to write my code, just give me ideas on how to solve my problem.
"It doesn't work" isn't good enough - Read this article

What have to you tried to code so far?
What part of what you have tried isn't working?
Are you getting error messages, or is it just not giving you the results you wanted?

(In other words, you at least have to make and show us your good faith effort to do your own coding. We are here to help you, not do it for you.)
What does this error mean?

Suggestion:
Don't replace lines of code that don't work. Instead comment them out and put your new attemps below that. This will keep you from re-trying the same ideas over and over. Also, when you come back to us saying "I've tried this 100 different ways and still can't get it", we can actually see what you tried. So often a failed attempt is very very close and just needs a little nudge in the right direction. So if we can say "See what you did in attempt 3... blah blah" it helps a lot

// Try #1 - May 1, 0900hrs
//    code
//    code  
//    code
// Try #2 - May 2, 1700hrs   Okay, plan B.  What if I do it *this* way
//    code
//    code  
//    code
// Try #14 - May 3, 0500hrs after 5 cans of RedBull.  Maybe I should get some sleep. I can't think of anything else but this last idea
    code
    code  
    code


If you are using Visual Studio you can select a block of lines and hit control+k control+c (Kode Comment) to comment it out. control+k control+u (Kode Uncomment) to uncomment a selected block.
Was This Post Helpful? 1
  • +
  • -

#3 BigdWiki  Icon User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 14
  • Joined: 22-November 11

Re: Searching an array

Posted 31 January 2012 - 02:58 PM

Wow. How useless you are, "tlhIn`toq". And by your name it says "mentor". What a joke! I coded the problem, and posted what I've written. Obviously its not working, otherwise I wouldn't have posted here.

If you see what I'm doing wrong, please let me know. Otherwise, there is no need to post garbage like that.
Was This Post Helpful? -2
  • +
  • -

#4 Neku  Icon User is offline

  • D.I.C Regular

Reputation: 20
  • View blog
  • Posts: 268
  • Joined: 21-May 09

Re: Searching an array

Posted 31 January 2012 - 03:15 PM

three things:
1) be nice to other people and watch your tongue! no one here get paid for helping on this site and even if people were to gain money for this you have no right to talk this way!
2) the code you posted is not VB6 but vb.NET so post it in the right forum next time.
3)unhappy with the help you get here then you can just go! dont waste people's time here!
Was This Post Helpful? 0
  • +
  • -

#5 BigdWiki  Icon User is offline

  • New D.I.C Head

Reputation: -4
  • View blog
  • Posts: 14
  • Joined: 22-November 11

Re: Searching an array

Posted 31 January 2012 - 03:18 PM

View PostNeku, on 31 January 2012 - 03:15 PM, said:

3)unhappy with the help you get here then you can just go! dont waste people's time here!


That's some sound advice, and I'm taking it.
Was This Post Helpful? -2
  • +
  • -

#6 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5316
  • View blog
  • Posts: 11,374
  • Joined: 02-June 10

Re: Searching an array

Posted 31 January 2012 - 03:36 PM

View PosttlhIn`toq, on 31 January 2012 - 03:53 PM, said:

Who says you're missing anything? Are you having errors or crashes?

"It doesn't work" isn't good enough - Read this article



View PostBigdWiki, on 31 January 2012 - 03:58 PM, said:

Wow. How useless you are, "tlhIn`toq". And by your name it says "mentor". What a joke! I coded the problem, and posted what I've written. Obviously its not working, otherwise I wouldn't have posted here.

If you see what I'm doing wrong, please let me know. Otherwise, there is no need to post garbage like that.


Ok. Let's try this from a different direction. Your first message only said "Is there anything I'm missing?" Which for all any of us could interpret meant "Do you say any part of the instructions that I failed to code?" IE. Something you missed. Not something you did wrong. It didn't even mention that you *had* a problem, let alone hint at what the problem might be. Even after your childish rant you still failed to tell any of us what the problem is. How can we help you to fix something if you don't tell us what is broken?

I'm not sure what 'mentor' means in your native language. But in English it means

Quote

a wise and trusted counselor or teacher.
and is synonamous with adviser, master, guide, preceptor.

It does NOT mean... Your code monkey, your mind reader or your verbal abuse whipping boy.

In the absence of any specific information or explanation from you the only response available was to ask you what type of trouble you were having and provide some helpful, albeit generalized information.

Now I'm willing to give you a second chance before putting you on my personal "Do not help" list. I recognize that we all have bad days.

If you would like to take a moment to regain your composure, then come back and write a decent explanation of the problem... maybe detail in what way you aren't getting the results/behavior you expected... screen shots of error messages... In other words, help us to help you... And do so in an adult manner that lets the professionals here know you are appreciative that they graciously donate their time to helping the next generation of coders develop their craft.
Was This Post Helpful? 3
  • +
  • -

#7 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,755
  • Joined: 26-March 09

Re: Searching an array

Posted 01 February 2012 - 01:14 AM

A couple of things.

Your code is VB.Net, so you'd be better asking for it to be moved to the correct forum.

That being said, on the absence of any description of your error, as a suggestion, have a look at the call to your function, how you check the result and your return types from the function.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1