Eagletalon 34 Junior Poster in Training

cool man... give it a try, see how it goes, and if you manage just remember to mark the thread as solved

Eagletalon 34 Junior Poster in Training

uhm... WaltP, point 4 on your list is not "main" but "menu"... and I believe it can be void...

and the semicolon in point 3 is an end while the rest should just be spaced into a new line as an variable of the struct (I hope I said it right)

Ron Walt is correct on his points though he seems very irritated and quick to show out problems, thats the general coder way, try making your code easier to read and please dont be afraid of open lines and indentation... eg:

struct BuyerInfo
{
    int id;
    string fn;
    string mn;
    string ln;
    string ad;
};

BuyerInfo info;

and now, see BuyerInfo as a "datatype"... info as a variable of that type...

how would you create an array of 100 integers? apply the same

Eagletalon 34 Junior Poster in Training

I think he got confused between the Get method vs Set method...

also that specific error arises because you are trying to send to the function a variable in the main function but that variable is not declared or created in the main.cpp

Walt your posts can stand on their own but for a complete noob he wont understand a word, I know you are getting frustrated and trying to get the people to brush up on the basics, but I dont believe they will know where to brush up on if you dont give a reference,

that said, giving them code that explains everything also isnt the way to do it

WaltP commented: Yuo need to keep your *assumptions* about peoples mental states out of your posts. You on the edge of a Rules Infraction. -3
Eagletalon 34 Junior Poster in Training

I agree... its a decent way to check the outcome of your functions... alternatively you can use a try catch... but it comes down to the same

Eagletalon 34 Junior Poster in Training

Allright in visual studio, at the top you will see a dropdown box with the text "debug"... change that to "release"... then build the application...

now in the folder you saved the project there will appear a "release" folder, in this folder will be the files you want, this can be run outside your application as an .exe file

Eagletalon 34 Junior Poster in Training

Hahaha then I guess my work here is done ;)

just remember to mark the thread as solved... and good luck further :D

Eagletalon 34 Junior Poster in Training

Haha bloody well done... sorry I dont normally log in from home so I didnt get your updates...

If you think this is a stable version then I am highly impressed that you made it work by yourself... its a quality you need to develop, because I believe more than 90% of programming is solving problems (hence the forum was born)

I have 1 other suggestion for you though... if you believe your application is solid, have someone test it with the intention of "breaking" it... errors are absolutely unwanted in any application, warnings and confirmation requests is a good thing though, keep that in mind...

Eagletalon 34 Junior Poster in Training

another basic check you can perform to block to much working is to see if the input is 1... IIRC square root of 1 = 1 so no need to calculate

Eagletalon 34 Junior Poster in Training

ok first thing... in the case of an user inputting a negative value... what happens?

in the case of an user entering letters... what happens?

unfortunately in software development you HAVE to handle the possibility that your user is an idiot... (no offense intended)

try doing something like a while loop around your initial input that breaks out when the input in valid

Eagletalon 34 Junior Poster in Training

yeah the structure you can work on yourself... depends on what you want it to look like...

remember that as long as it makes sense you can put it into more than 1 line, you can change around, what ever you want... kind of the programmers right ;)

Eagletalon 34 Junior Poster in Training

that looks much better... And I agree with zeroliken... ok how about the following:

cout << "Starting calculation" << endl << endl;

while (fabs(value2-value1) > 0.0001)// for float absolute values

           { 

             cout << "Starting loop" << endl;

             cout << "Starting value: " << value1;

             value1 = value2;

             cout << "Overwritten to: " << value1;

             value2 = (value1 + value/value1)/2;

	     cout << value2 << endl;

}

Build further on this... try to always make your output descriptive and complete, then everyone can know what is going on

Also remember to make it easy to read... add in endl commands and spaces... get everything to display easy to read... just makes it easier in the future

Eagletalon 34 Junior Poster in Training

Please try to enter your code in the correct code tags... (ends with "[/code]")

So what stops you from just using "cout << current value" in the correct spot?

is this your own code? because I mean there is LOADS of cout and user communication, writing all that surely you understand giving output and how and where to do it?

Eagletalon 34 Junior Poster in Training

I dont recognize the datatype "CToolBar"... is this libraries added to C++?

Eagletalon 34 Junior Poster in Training

Replaces the variables Y and N by a variable 'Answer' of type char which also receives user input (Y or N), and on condition of while loop you can see if it is equal to Y. So if it is equal to Y, the cycle repeats. For maximum effectiveness could you put the functions

cin >> Answer;

into another cycle to repeat while the user did not enter Y or N. Instead of always repeating unnecessarily

cout << "Please enter the third program score (0-100):";
cin >> score;

you could also write this only once within a cycle that is repeated as often as thou wilt, keeping the value received from the keyboard in a vector of variables; makes you much to code view.
I hope this helps.

Here Al41007 gave the code of

cin >> Answer;

But you never declared "Answer" as a specific datatype... declare it before that line and it should take away the error

Eagletalon 34 Junior Poster in Training

Think of a function as a building,

You can walk down the hall all the way, and when you get to a room the door/walls etc belong to that room, (room = loop, if, case, etc)

You cant access the door from the next or the previous room in the room you currently are (now don't get technical and create doors from 1 room to the other :P, this example there is only a hallway and the rooms branch from that) ;)

Eagletalon 34 Junior Poster in Training

Look what Walt is trying to say is:

char rank;

 

	for (int i=0; i<numFaculty; i++)

    switch(rank)

^
this code makes no sense whatsoever... you are creating a new variable "rank" then you are checking its value,

but is has not been assigned any value? the case will never find what you are looking for

We have no idea what you are checking for so we cant tell you what to do with it or how to do it, and to be honest even if we did we aren't going to give you all the answers on a silver platter

but you need to fill a variable before you check it otherwise it is completely useless?


It would seem as though you dont have a clearly defined plan of your program, its flow or variables, and planning it out like Walt suggested will give you a much better idea of what is going on

Eagletalon 34 Junior Poster in Training

Look at it this way...

X is a variable right... P is a pointer that points at X (p = &x)... * means pointer and & means reference (http://www.cprogramming.com/tutorial/lesson6.html)

now think of P as kind of a portal to access X... anything you enter into P actually gets set in X, and setting X also changes P because its like looking through a portal at the same thing...

When sending variables to a function, it is much better to send a pointer or a reference because you can then in the function change the value of the variable and when you get back to the previous method the value is still changed... This is also VERY resource effecient

alternatively sending a variable without a pointer or reference indication creates a second variable with the same value and uses more resources

Coding Example:

void MyClass::ParentMethod(){

    int var = 0;
    
    changeVar(*var);

    cout<<var<<endl; //outputs "4"
}

void MyClass::changeVar(int& var){

    var = 4;

}
Eagletalon 34 Junior Poster in Training

Well theoretically if you say "pointer = new class()" and you allocate memory to it then yes you would have to...

the core programming stays C++, only C# users are blessed with the garbage collecter

Eagletalon 34 Junior Poster in Training

What I usually do is I inherit my main class from the UI, that way I can run the functions as follows:

setupUi(this);

QString text;

text = this->lineEdit->text();

the whole thing with the "ui->member->function" is to be able to handle multiple forms better, that way you need to specify the parent of the widget to access the correct one...

its like working in a database in SQL, you can either use "SELECT * FROM MyTable" or you can use "SELECT * FROM MyDatabase.dbo.MyTable"...

Eagletalon 34 Junior Poster in Training

I believe the issue is that the controls you have added to the ui are not named in the same way in the ui's header file... you can try to rename them manually if you cant recompile the header

And I am sorry to ask this, but are you certain you changed the name in the correct field? QT Designer has 2 fields namely "Object Name" and "Text"...

Eagletalon 34 Junior Poster in Training

Ey mate... I use QT myself... how do you compile your program into a VCproject?

I personally use qmake command in command prompt, if this is how you do it as well just run it again with the application closed and it should update all the ui changes into your project

Eagletalon 34 Junior Poster in Training

What WaltP is trying to slow walk you to is dividing the amount by 16 (hexa),

how hexadecimal works is that you take the decimal amount, divide it by 16, take the fraction (after the decimal point) and multiply this by 16, then take the integer remainder (before the decimal point) and repeat the process until the dividing results in a value smaller than 1,

then you take the hexadecimal values (found by the multiplication) and turn it back to front...

this process can be found here www.permadi.com/tutorial/numDecToHex/

I wont give you the coding, sorry mate but you'll have to work for it, but I think this will give you what you need if you want to solve it yourself...

thus: 405678
step 1:

405678 / 16 = 25354.875.. take 0.875

25354 / 16 = 1584.625... take 0.625

1584 / 16 = 99.0... take 0.0

99 / 16 = 6.1875... take 0.1875

6 / 16 = 0.375... take 0.375

step two:

0.875 * 16 = 14 = E

0.625 * 16 = 10 = A

0 * 16 = 0 = 0

0.1875 * 16 = 3 = 3

0.375 * 16 = 6


Step three:EA036 -> 630AE


Hex value = 630AE

HINT: Step 1 and 2 can take place within a single loop

Eagletalon 34 Junior Poster in Training

http://www.daniweb.com/software-development/c/threads/114052

Follow that link and lets see if you can find the answer yourself...

This isn't really an error and wont kill your program... so lets see if you can get it... :P

work for your major ;) :D... best of luck buddy

Eagletalon 34 Junior Poster in Training

My apologies I also made a mistake... should be if(issquare())... typo on my side

Keep it as Rectangle::isSquare()... just make it a bool and give it a try

Eagletalon 34 Junior Poster in Training

Alright you have 2 errors there... I think keep it as it is (in PrintInfo()) but remove the text "Rectangle."... so it looks like:

void Rectangle::printInfo()
{
	cout << "the length is " << length << endl << "the width is " << width << endl;
	cout << "the perimeter is " << perimeter << endl << "the area is " << area << endl;
 
	if(isSquare)
		cout << "the rectangle is square" << endl;
	else 
		cout << "The rectangle is not a square " << endl;
 
}

then we check the other error if it is still there

Eagletalon 34 Junior Poster in Training

Which if gives you the problem?

Also on the function data types... something like "calculate perimeter" I would make a void function... but then you dont have a line in that function with "return"... you just leave it out...

In the case of "IsSquare()" I would make it a bool and use it in a way like:

if (object1.IsSquare(){

    cout << "Object 1 is a square" << endl;
}

then the return would be a true/false ofcourse

Eagletalon 34 Junior Poster in Training

Yeah as I said... a function declared "void"... (eg. void Rectangle::isSquare()) can not have a "return"... just take out those lines and the errors should cease

Eagletalon 34 Junior Poster in Training
void Rectangle::calculatePerimeter()
{
	(length * 2) + (width * 2) = perimeter;
		return perimeter;
}

The errors in the code above show up as are right next to the first "(" brace and it says "expression must be a modifiable value" Second one is on my " return perimeter" and it says " Return value type does not match function type"

alright here I can see 2 things that are troubling me... 1st place a function declared as "void" can not have a return type... so if you take that away the error should disappear...

And secondly: "(length * 2) + (width * 2) = perimeter;" should this not be -> "perimeter = (length * 2) + (width * 2);"? as you assign the value?

void Rectangle::calculateArea()
{
	length * width = area;
		return area;
}

on "length" it says "expression must be a modifiable value" and the other one is under "return area" and it says "return value type does not match function type"

Again the same 2 problems

void Rectangle::isSquare()
{
	return fabs(length - width) < .0001;
}

under "fabs" it says "return value does not match the function type"

and again with the return in the "void" function...

also when working with a return, I make it my standard practice to always return a already set variable rather than a calculation... easier to debug and find problems... but thats just me

so no real big problems just a bit of a syntax …

Eagletalon 34 Junior Poster in Training

Alright mate, first thing is first... bloody well done on getting this far by yourself, unlike many others that use this forum you actually tried and deserve recognition for that fact...

now what are you having troubles with? do you have compiling errors or are you having incorrect or not anticipated output? or do you not know where to go or what seems to be the problem here?

Eagletalon 34 Junior Poster in Training

It means that there is a possibility that an condition or a loop statement flow results in a path without a return value

i.e. function runs and is expected to return a value but there is a possibility that it wont and thus create an application error...

all the compiler is telling you is to clean up and ensure you ALWAYS have a return :)

If you dont need any data returned... try declaring the function as a "void" or simply returning a 0 (numeric types), ""(text types), true(bool) etc

Eagletalon 34 Junior Poster in Training

That's because your regional settings is US or any other that has MM/DD/YYYY.
If I where to run it I would get the same error (I'm Greek = DD/MM/YYYY).

Wow... there I learned something awesome :D... thnx man... oh and btw I'm from South Africa and I believe the setting fall under UK? :S nevertheless if that solves it then bloody well done, wouldn't have thought of it in years

Eagletalon 34 Junior Poster in Training

It runs perfectly for me?

QUERY:

SELECT DATENAME(MONTH, CONVERT(DATETIME, '5/28/2011')) AS ReceivedMonth

RESULTS:

May
Eagletalon 34 Junior Poster in Training

Hi jovillanuev

Error:
Msg 241, Level 16, State 1, Line 2
Conversion failed when converting datetime from character string.

This error is 1 I've had many times over... it means that the string you are using for a date is not in a valid format for SQL to interpret...

Could be something like: "201121 14:35"...

would it be possible to just select the string to see the output? give us an example of what needs to be converted

Eagletalon 34 Junior Poster in Training

Try the following?:

SELECT ItemNumber,	
             PurchasePrice,
             ReceivingPO,
             DATENAME(MONTH,CONVERT(DATETIME, ReceivedDate)) AS ReceivedMonth
FROM #VPTable as vp
WHERE vp.ReceivingPO IS NOT NULL
adam_k commented: I stand corrected +7
Eagletalon 34 Junior Poster in Training

Could you possibly provide some example data? perhaps the record that "breaks" the insert? (you mentioned the first 6 works, perhaps nr 7 is a problem?)

Eagletalon 34 Junior Poster in Training

is it possible the data contains characters that would "break" the insert? eg. a VARCHAR value like: 'Stan's bbq'