Computer Help forum

General discussion

Help with VB coding PLEASE!!!!!

by Lu15 / May 3, 2005 3:15 AM PDT

Can someone please help me do a code for finding the mean medium and mode for numbers inputted into 8 text boxes?!

Discussion is locked
You are posting a reply to: Help with VB coding PLEASE!!!!!
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: Help with VB coding PLEASE!!!!!
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Collapse -
That's a nice assignment.
by Kees Bakker / May 3, 2005 6:17 AM PDT

It's easy to do in Excel (these are 3 of the many Excel functions).

The mean wouldn't be to difficult in VB (add and divide, after testing which are filled in and numeric). The others definitely are more work, they need sorting, searching, counting, best to do as an array manipulation. That would take some time to do in any programming language that doesn't have such basic statistical functions. Either do it yourself, or find a programmer for $50 an hour (he can do it within a day, I think), or search on google or in the books.
But you learn a lot by doing it yourself, provided you've got ample time.

So why not use Excel?


Collapse -
In Hartford, CT that's 210 an hour buddy.
by R. Proffitt Forum moderator / May 3, 2005 6:24 AM PDT

But I'm not there so I don't get that much. I also think I lack the laser stare at the screen.

Collapse -
A day?
by Yew / May 3, 2005 8:03 AM PDT

If a program like that takes you more than about an hour, you've got problems. In all honesty, it shouldn't take more than 20 minutes, and that's if you're really picky about widget placement and sizing.

First thing I'd do, is create a module with generic median, mean, and mode functions. Then I'd just call those functions, passing in the values of the text boxes, and returning the end result. All in all, probably 10 minutes work, tops. Maybe 15 if you're using VB.NET, since you have to use some .NET methods to convert the text box data from a string to an integer.

Collapse -
by Lu15 / May 3, 2005 8:25 AM PDT
In reply to: A day?

thanks for giving me information, but i'm just i beginer, and i have a horrible teacher who doesn't teach and doesn't know how to help us, so i dun know what modules and stuff are. Perhaps there is an easier explination?!

Collapse -
by Yew / May 3, 2005 9:06 AM PDT
In reply to: Re:Help

I don't do other people's homework. That's what TAs, books, and all kinds of other resources are for.

I've already outlined the basic procedure for you, you just have to figure out how to implement it.

Collapse -
by Kees Bakker / May 3, 2005 5:04 PM PDT
In reply to: A day?

Do I understand correctly that VB offers ready-made functions for mean, medium and mode? Then, I agree, it's simple.

I don't know enough of VB, so I assumed this was an exercise meant to program that yourself. And then stuff with loops and arrays comes in, and that needs some care to get it right. But you learn a lot of basic programming doing it. That's why I called it a 'nice assignment'.

Just setting up a screen and calling three existing functions isn't real fun.



Collapse -
It might
by Yew / May 3, 2005 9:41 PM PDT
In reply to: Yewanchors,

Now that I think about it, it's quite possible that it does. At least VB.NET might anyway.

But I was actually talking about writing your own functions, then sticking them into your own sort of library.

Collapse -
That would take more than 10 minutes ...
by Kees Bakker / May 3, 2005 10:25 PM PDT
In reply to: It might

to write a module to find the median and the modus for (for example) 1,5,7,2,3,5,1,6.

The median is 4 (the mean of 3 and 5 after sorting to 1,1,2,3,5,5,6,7).

The modus (according to Excel) is 1. But it could just as well be 5 (because both 1 and 5 occur twice), or undefined (for the same reason). I couldn't find an exact definition in this case.

And, of course, I agree with you on not doing homework for somebody else. You only learn from an assignment by doing it yourself.


Collapse -
Not necessarily
by Yew / May 3, 2005 11:47 PM PDT

If you write the function generically enough, it really shouldn't be a problem. Unless you're planning on writing your own sorting method, but even then, a simple bubble sort takes all of like 6 lines of code in most languages. It's inefficient as hell, but it works, and quite well at that. It's also very easy to understand and implement.

But ultimately, a person has to do their own work, or they don't really learn anything. I've recently got into developing web apps with Ruby on Rails. Very slow going at first, I kept making real simple, and subtle mistakes. I spent almost an entire day trying to figure out a solution to a single problem, and it was rather satisfying when I finally came up with a solution.

Collapse -
No you wouldn't...
by Edward ODaniel / May 4, 2005 3:31 AM PDT
In reply to: A day?

you would do it within the parameters set out by the textbook or the specific instructor.

Collapse -
without asking Lu15 how old he is
by jonah jones / May 4, 2005 3:50 AM PDT
In reply to: No you wouldn't...

and is that assignment for school or college, i'm sure you might remember that most (if not all) teachers, be it high school or college, don't want answers, they want the method....

which means that Ed is right when he says "you would do it within the parameters set out by the textbook or the specific instructor", cos' if you don't, no matter how correct your answer, you may just fail the test...


Collapse -
by Lu15 / May 4, 2005 8:30 AM PDT

i'm not a guy, i didn't come here asking for the answers, i asked for HELP because i'm having difficulty with finding a way to do a coding for a programing. i have been looking through my textbook, my teacher is terrible at teaching, i ask him to explain things and he doesn't know what they are, he even gets other students to go help people becuase he's bad at it. I came here hoping someone might help me. Not do it for me.

Collapse -
It's a sad day.
by R. Proffitt Forum moderator / May 4, 2005 8:32 AM PDT
In reply to: Reply

The google I supplied revealed how to do this.

If you can't use that, what more is there to do but just give you the full solution?


Collapse -
There seems to be some misunderstanding here.
by Kees Bakker / May 4, 2005 5:47 AM PDT
In reply to: No you wouldn't...

I get the impression that Edward means to say that one would do best to conform to the context of the text book or the instructions of the teacher. And that you understand that he says you wouldn't be able to do it in 10 minutes or so. Although the subject line could be interpreted like that, the contents of the message don't support that interpretation at all, in my opinion.

I think you would do well to acknowledge the misunderstanding and apologize for your unnecessarily rude answer. Regular visitors might know you that way, so here's a chance to prove you're a nice guy after all.


Collapse -
They wouldn't
by Yew / May 4, 2005 8:54 AM PDT

Now that this has completely derailed...

Textbooks only really cover the basics. Syntax rules, maybe library methods, but they don't really teach the HOW of programming. That is really only something you can learn by doing, and as such, everyone develops their own style over time.

I outlined the method by which I would solve this particular problem. Someone else might decide to duplicate effort and just write out the code to calculate things every time. Others might pipe the data to another program for processing, and then just present the results. Some people may use a bubble sort for ordering things, someone else may use a shell sort, etc.

There are so many different ways you could approach a program like this... Of course I did have a bit of an arrogant ******* for a class early on in my college career. It was a class on C++ all MIS undergrads had to take. I already happened to know most everything that was going to be taught, so I started screwing around a little. I made an object-oriented hello world program for example. Complete code bloat, I admit, but it met the requirements for the assignment. ******* still gave me a zero for it... Still, I like to think I had the last laugh. Before I graduated, the guy was no longer teaching at the school I went to. I like to think my making an issue of it with two different department chairs had something to do with it.

If the instructor is that bad, drop the class would be my advice to the original poster. If it's a high school class, who cares. It's almost certainly an elective, so who cares if you get an F? If you really want to learn programming, you can pick up a better book on VB or some other language (I might recommend Python or Ruby). I have one of the O'Reilly VB books, and it's actually not too bad. It's amazing that it's written by the same guy who wrote the infamous "Teach Yourself C++ in 21 Days" book. It's well known in most C++ groups as probably the worst C++ book there is.

Popular Forums
Computer Newbies 10,686 discussions
Computer Help 54,365 discussions
Laptops 21,181 discussions
Networking & Wireless 16,313 discussions
Phones 17,137 discussions
Security 31,287 discussions
TVs & Home Theaters 22,101 discussions
Windows 7 8,164 discussions
Windows 10 2,657 discussions


Help, my PC with Windows 10 won't shut down properly

Since upgrading to Windows 10 my computer won't shut down properly. I use the menu button shutdown and the screen goes blank, but the system does not fully shut down. The only way to get it to shut down is to hold the physical power button down till it shuts down. Any suggestions?