473,789 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

help with my homework

ok i have gotten this damn project almost done but i am frustrated on
this one step. getting 18-35 together and 36-50 and so on. here is my
code how can i get them combined in one line instead of writing it out a
million times. please help me. i have to write a program that you type in
the age and it stores it in a text file then i have to catagorize them and
when i hit the read button it shows how many times 18-35 was typed in, then
how many times 36-50 was typed in and so on.

If strRecord.Remov e(0, 2) = 18 Then
strEighteen = strEighteen + 1
ElseIf strRecord.Remov e(0, 2) = 36 Then
strThirtySix = strThirtySix + 1
End If
Loop

it works if i put individual numbers in and continue it down but that is
alot of code and i am sure there is an easier way

oh also how can i get the program not to input the under 18 here is my
code am i missing something?

If Me.txtAge.Text <=18 Then
MessageBox.Show ("Your age must be 18 or older thank
you", "POA", _
MessageBoxButto ns.OK, MessageBoxIcon. Information, _
MessageBoxDefau ltButton.Button 1, _
MessageBoxOptio ns.DefaultDeskt opOnly)
End If

when i type in 17 for the age it still puts it in the text file. i need it
to not store in the text file if it is less than 18.
ok well that is my queestions please help me thanks very much

Tommy
Advanced Visual Basic .NET Programming Class
Jul 21 '05 #1
7 1771
Mostly we don't help with homework, however a little help to bring you on
the right thrack
If strRecord.Remov e(0, 2) = 18 Then
You probably mean Substring instead of Remove
strEighteen = strEighteen + 1
Using a string is not so nice you can use an Integer for that
ElseIf strRecord.Remov e(0, 2) = 36 Then
strThirtySix = strThirtySix + 1
End If
Loop

If Me.txtAge.Text <=18 Then
Why <=18 and not simple <18
MessageBox.Show ("Your age must be 18 or older thank
you", "POA", _
MessageBoxButto ns.OK, MessageBoxIcon. Information, _
MessageBoxDefau ltButton.Button 1, _
MessageBoxOptio ns.DefaultDeskt opOnly)
Else
do your storing
End If

Jul 21 '05 #2
First of all, what is "Advanced Visual Basic"?? Isn't that an oxymoron?

Anyway, my advice is that if you can't solve this trivial problem on
your own, either go back to "Basic Visual Basic" or pick a different
course of study, because you'll be screwed when you get to the
difficult problems.

JMHO.

Jul 21 '05 #3
"Patrick A" <pw*******@gmai l.com> wrote in message
news:11******** *************@c 13g2000cwb.goog legroups.com...
First of all, what is "Advanced Visual Basic"?? Isn't that an oxymoron?
Admittedly the juxtaposition of "Advanced" and "Basic" might seem
oxymoronic, but the fact of the matter is that there's very little that
Visual Basic.NET can't do as compared to C#. I do believe that the gap
between the languages will grow in future, e.g iterators, and anonymous
methods in C#2 and static form instances in VB.NET2 (shudder), but right now
they're on a pretty similar footing. If you can't have Advanced Visual
Basic.NET, you can't have Advanced .NET. Unless perhaps you feel that the
only advanced .NET programming is found in unsafe code blocks?
Anyway, my advice is that if you can't solve this trivial problem on
your own, either go back to "Basic Visual Basic" or pick a different
course of study, because you'll be screwed when you get to the
difficult problems.
And I take it you sprang from you mothers womb with a full-fledged knowledge
of all programming idioms? We should be encouraging beginners to learn
rather than trying to smash their self-confidence.

Keep in mind that the marketers for these courses call them Advanced this
and Expert that, but generally they all start off as beginner programming
courses, the difference between them being where they end up. Using the
courses name to hammer a beginner with hardly seems fair.

JMHO.

Jul 21 '05 #4
It's a shame that neither responder thought to actually help you.

First off, when you get a value as a result of an expression, and you want
to use it in a comparison, it is often best to store the value in a variable
of the proper type. You are taking a string and converting to an integer in
the IF expression. This is cool for VB, but it can lead to some confusion,
as you can see here. Also, if you are using the 'str' prefix to mean
'String' then you are adding an integer to a string, which causes TWO data
conversions (first from string to int for the addition, then back to string
for storage). Declare the counter variables to be Integer.
So, first off:
Dim Numval as Integer
Dim ct18 as Integer
Dim ct35 as Integer

Numval = strRecord.Remov e(0,2)

Now put that number into your logical expression:

If (Numval > 17) and (Numval < 36) Then
ct18 = ct18 + 1
Else If (Numval >35) and (Numval < 51) Then
ct35 = ct35 + 1
End If

Also:
oh also how can i get the program not to input the under 18 here is my
code am i missing something?

Your code block looks fine. It's the code that follows the End If that
worries me. You appear to be putting up a message box and then proceeding
with the logic. You need to have your routine return inside the 'If' block,
or put the logic for writing the record in an 'Else' block.

Good luck!

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"tjshadyluv er" <tj**********@d iscussions.micr osoft.com> wrote in message
news:B7******** *************** ***********@mic rosoft.com... ok i have gotten this damn project almost done but i am frustrated on
this one step. getting 18-35 together and 36-50 and so on. here is my
code how can i get them combined in one line instead of writing it out a
million times. please help me. i have to write a program that you type in
the age and it stores it in a text file then i have to catagorize them and
when i hit the read button it shows how many times 18-35 was typed in,
then
how many times 36-50 was typed in and so on.

If strRecord.Remov e(0, 2) = 18 Then
strEighteen = strEighteen + 1
ElseIf strRecord.Remov e(0, 2) = 36 Then
strThirtySix = strThirtySix + 1
End If
Loop

it works if i put individual numbers in and continue it down but that is
alot of code and i am sure there is an easier way

oh also how can i get the program not to input the under 18 here is my
code am i missing something?

If Me.txtAge.Text <=18 Then
MessageBox.Show ("Your age must be 18 or older thank
you", "POA", _
MessageBoxButto ns.OK, MessageBoxIcon. Information, _
MessageBoxDefau ltButton.Button 1, _
MessageBoxOptio ns.DefaultDeskt opOnly)
End If

when i type in 17 for the age it still puts it in the text file. i need it
to not store in the text file if it is less than 18.
ok well that is my queestions please help me thanks very much

Tommy
Advanced Visual Basic .NET Programming Class

Jul 21 '05 #5
> It's a shame that neither responder thought to actually help you.

Beg your pardon?

I thought I actual did, I see not anything you have added to my answer.

:-)

You know that I am smiling now.

Cor
Jul 21 '05 #6
Sorry about that,Cor. My ISP sometimes drops news messages. I don't see
your response.

(or are you just pulling my leg :-)

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:Ot******** ********@TK2MSF TNGP09.phx.gbl. ..
It's a shame that neither responder thought to actually help you.

Beg your pardon?

I thought I actual did, I see not anything you have added to my answer.

:-)

You know that I am smiling now.

Cor

Jul 21 '05 #7
Nick,

I dont use my ISP anymore, I go directly to (by instance for this newsgroup)

news://news.microsoft.com/microsoft....dotnet.general

Although Google is as well good at time.
http://groups-beta.google.com/group/...fdd860e5242b7c

And I never will write things that could confuse an OP, maybe a regular
understand it, however a newbie does not.

Cor
Jul 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
669
by: David | last post by:
with the onclick=openWindow() function I have to be able to pick a file and a location where I want that file to open. I have 4 files and 4 location. I know I have to write a if statement stating which file has been chosen and which location has been choosen then I have to click the button (open window) and it will open the file in the location I picked. Anyone has any idea how create the solution to this problem.
11
2002
by: The_Kingpin | last post by:
Hi all, I'm new to C programming and looking for some help. I have a homework project to do and could use every tips, advises, code sample and references I can get. Here's what I need to do. I have a file named books.txt that contains all the informations on the books. Each book is a struc containing 6 fields written on separated line in the
45
4306
by: davy.zou | last post by:
I have started learning c++ and I need help. I need to write a program, the question is as follows. At a post office, there are a certain number of 2, 7, and 9cents stamps, now, given a total number of cents required, find the correct and most effective combination of stamps. meaning that if you were to need 14cents, the correct output should be 2 seven cents not 7 two cents.
3
1398
by: azzuri | last post by:
Hi, The title seems vague, but i could not think of anything more descriptive. I am creating a database and i am a bit stuck. I have started to create a database for pupils in a school. I have created the tables, includes: Pupil (containing pupil information, class etc) Homework (containing homework information) Complete (table linking the above, and a check box to determine if a pupil has completed a homework or not)
62
2734
by: vubaboota | last post by:
I HAVE SOME SERIOUS PROBLEM , HOW TO MAKE A PROGRAM IN C Q1: Write a program using malloc function. In which you take input from user and allocate memory equal to square of this number. Which multiply numbers and draw a table in the following format? Hint: User enters 3 then program allocates equal to 9 integer memories. Output:1
19
1967
by: mohammaditraders | last post by:
a program which consists of a class named Student, the class should consists of three data members Name, Ob_marks, Total_marks and two member functions Cal_percentage() which calculate the percentage of the student by the formula (Ob_marks * 100 ) / Total_marks and Display() which show all information of the student. The class should also contain the default constructor which initializes all the data member of the class. In main program...
20
1952
by: zerobinary | last post by:
#include <algorithm> #include <iomanip> #include <ios> #include <iostream> #include <string> #include <vector> using namespace std; int main () { cout <<" plz enter your first name: ";
1
1570
by: gator6688 | last post by:
I need to be able to save my additional data to my .dat file. The additional data is not part of the vector though. It is data I made after the vector. I have to save the finalGrade and letter grade to my file.Also, how can I save my letter grade to my file when I didn't actually name it that? #include "stdafx.h" #include <iostream> #include <fstream> #include <string> #include <cstdlib> #include <iomanip> #include <cmath> #include...
8
29171
by: garyrowell | last post by:
I have been at this programme for hours trying to work out what is wrong. Any help would be very much appricated. Here is the breif I received. The program This week you are going to write three classes: Card.java, Deck.java and DeckTester.java. The specification for each class is given below. Card.Java This is a simple class that represents a playing card. Card has two attributes: • rank which is a String that represents the value...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10412
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.