|
I think, there is no maximum for the size. I've tried it and it works:
this.Size = new Size(1280, 1024);
|
|
|
|
|
Hi there, my name is Ami. I am currently a student at DeVry University and am taking my first programming class! I am ready to pull my hair out because I can never get any of my programs right and I really want to understand this stuff. (by the way I'm taking C# programming online)
I have a lab that I need help with....I have to design a solution with a Main() method that holds an integer variable named seconds to which I assign a value, create a method to which you pass the value, the method displays the seconds in minutes and seconds (66 sec. = 1 min and 6 sec.)...I go there from hours and so on, if anyone could give a jump start in the right direction I would appreciate it. Thanks, Ami
Ami
|
|
|
|
|
Have you tried DateTime (And it's static members like DateTime.Parse() etc...?)?
turn it to DateTime and it will be easyer then deviding it by 60 and by 24...
|
|
|
|
|
NaNg15241 wrote: Have you tried DateTime (And it's static members like DateTime.Parse() etc...?)?
turn it to DateTime and it will be easyer then deviding it by 60 and by 24...
True, but that is not the point of the exercise. The exercise is trying to teach basic concepts, using examples that everyone will understand, such as how to simple maths in a computer language.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Basically this is what I have so far...
using System;
struct Time
{
public Time(int hh, int mm)
{
hours = hh;
minutes = mm;
seconds = 0;
}
private int hours, minutes, seconds;
}
Time now = new Time(12, 30);
Console.WriteLine(now.hours);
Console.WriteLine(now.minutes);
Console.WriteLine(Now.Seconds);
Ami
|
|
|
|
|
betty_boop wrote: if anyone could give a jump start in the right direction I would appreciate it
Well... Lets see what you know, then we can concentrate on teaching you the bits you don't know.
1. Do you know how to create a method?
2. Do you know how to call a method?
3. Do you know simple maths (such as 66 divided by 60, and 66 modulus 60)?
4. Do you know how to create a variable? And assign a value to it?
5. Do you know how to write information to the console? (This lab appears to be a console application)
For every "yes", you are part way to the solution. If you answer "yes" to all, then you need to learn how to put it all together in order to get your program working.
So, what are your answers to the above questions?
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
I am comfortable saying that I know 3,4,& 5 but a lost on 1 & 2
Ami
|
|
|
|
|
Well, looking at your other post, you seem to have a handle on creating struct s (which is a little more advanced than I'd expect)
You create a method inside a class or struct . struct s are rarely used, but for the most part are very similar to a class . They, struct s, are passed "by value" rather than "by reference". Passing by value means that the "value" is copied when it is passed to a method or assigned to a new variable. Passing by reference means that only a reference to the object is passed, not the object itself. This means there is only one copy of the object.
For the rest of this post every time I use class you can also assume it will work with a struct also.
Now, to create a method you need to know some things.
1. What is it going to be called? Typically method names are verbs or verbal phrases. That means they indicate what they are going to do. e.g. CalculateTime
2. What information does the method need to know in order to work? Because a method is part of a class or struct, it will be able to see the information that the class holds. If the class doesn't hold the information that the method needs it will have to be passed in as parameters. So, a method may need parameters.
3. What information is return ed? Not all methods return information, sometimes they just modify the class they are part of. But if a method does return some information you need to know what that is. Is it a string ? An int ? a DateTime ?
4. What can see the method? Is is public , private , protected , internal , or internal protected . Don't worry about all these choices at the moment. The two most common are public and private . public means that everything can see the method, private means that only the class (or other instances of the class ) can see the method.
So here is an example all put together:
public Time CalculateTime(int seconds)
{
}
1. It is called CalculateTime
2. It needs to know how many seconds to use is the calculation. And it needs to know that seconds is an int .
3. It returns a Time object (from the struct I saw in your other post)
4. It is public , which means that anything that has an instance of this class can use it.
The next thing you need to know is how to call the method.
As the method return s something you need somewhere to store that (assuming you are interested in the return value - It is perfectly okay to ignore the return value if you want). In this case we need a variable of type Time .
We also need to know what to pass in to the method. In this case we can use a literal value that is hard coded into the application, but you can use a variable of type int (because that is what the method expects) if you want.
Time calculatedTime = CalculateTime(66);
And that is it.
Does this help?
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
Yes, that does clear things up a little. The actual "struct" that I was using, I'm not allowed to for this assignment(just asked my professor), so I had to redo it. I did set the method to CalculateTime, let me play with it for a minute and I'll let you know what I come up with...thanks for all your help I truely appreciate it!
|
|
|
|
|
|
:->
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
This is what I have, and I know I am totally off. I thought I would like programming, but I have never been so frustrated in my life!!!!!
using System;
public class CalculateTime
{
public static void Main()
{
int s=0, Totalmin=1, h;
int TotalTime = 1, Total;
}
public static void CalculateTime()
{
while (s >= 0)
//calculate min. to sec.
for (s = 0, s > 60, ++s)
if ((s % 60) !=0)
{
TotalTime = TotalTime + h;
Time++;
h = x + 1;
}
}
Total = Totalmin % s;
Console.WriteLine("The time is: {0}", Time);
}
Ami
|
|
|
|
|
betty_boop wrote: I have never been so frustrated in my life!!!!!
Yeah! But it is such a wonderful feeling when it all works out!
Okay - The code you have probably doesn't even compile. Code can only exist within methods (and Properties - but I'm guessing you haven't got that far yet)
First, you are thinking about the whole thing sequentially (which is common for a beginner). Think about calling method like looking up an entry in the dictionary or an encyclopaedia (The methods themselves are like the entry in the book). You don't read a encyclopaedia from start to finish. You jump in where you need to. You might want to read an article about Edinburgh, and it mentiones a famous ex-resident, Sean Connery, and you want to know more so you skip to that entry, and it mentiones James Bond movies so you jump to that entry. The editor that compiles the encyclopaedia isn't going to know what order you want to read in so cannot compile the book in the order Edinburgh, Sean Connery, James Bond. The only sequential things is the normal reading order of the sentences and paragraphs within an entry. In a program the developer doesn't know what order the methods will be called in (typically - your examples are simple enough that you can tell in advance, but when you get to interactive stuff it all depends on the user making descisions at runtime)
Next thing is that a method knows nothing about anything before it was called unless you tell it (by passing in parameters, or if the information is available by calling other methods, from class fields or properties - don't worry about all that just now, at this stage I think concentration on passing in parameters is what your professor is interested in)
Going back to your original description of the problem:
betty_boop wrote: I have to design a solution with a Main() method that holds an integer variable named seconds to which I assign a value, create a method to which you pass the value, the method displays the seconds in minutes and seconds (66 sec. = 1 min and 6 sec.)...I go there from hours and so on,
That means the Main method needs very little
int seconds = 66;
DisplayTime(seconds);
That is all that your Main() method needs.
The more complext thing is creating the DisplayTime() method.
You have a loop which you don't need. Some of the maths may feel a little odd to start with but you'll begin to recognise common patterns soon enough. The trick is to think ahead a little and figure out what you are going to need and see if you can get that a better way - Don't worry, this will start to come naturally once you are practiced more. Which is, of course, the purpose of the exercises you are being set.
There are 3600 seconds in an hour .
hours = seconds / 3600;
There are 60 seconds in a minute, but we also need to discount the hours from the total number of seconds.
remainingSeconds = seconds - (hours * 3600);
The calculation for the minutes is now similar to the hours , but divide by 60 . Then the calcualtion for the remainingSeconds is similar to the one above also, but multiplying your calculated minutes by 60 .
So you now have hours, minutes and remainingSeconds which you can output using Console.WriteLine();
So, hopefully I've given you enough that you can re-write your code so that it gets you closer to your goal.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
I appreciate all your help Colin. And I understand what you were saying how it get's better when the programs actually work. The very few programs that I did get to work, it was great, made me think I actually wanted to doing programming. But now, I know these problems are actually simple and me not being able to get them, and spending all week on this is driving me crazy. Even with your help and the professors I don't understand why I still can't get it! I think this is a class I should have tried to take in an actuall class room, to get the one on one, instead of online!
Anyway, I still didn't get it to work. I have to take my exam now, when I'm done, I'll work on it some more, but it's due by midnight tonight, so even if I don't get it to come out right I am still going to turn it in.
Thanks for all your help, you have made some things clearer for me and I truely appreciate that.
Ami
|
|
|
|
|
Ok, this seems basic I know but for some reason it's giving me troubles. I have a checkbox on an asp.net page that gets checked...however, there is no postback going to happen on a button click. My question is how can I get the value of the checkbox without a postback?
I created an event and wired it to my continue button, once fired it does the validation. The client didnt like the fact that the page posted back when the checkbox was clicked (I was saving what was checked on postback). So I created this event.
I am able to get the control and everything, but it's telling me the Checked if false, when I know I checked it.
Here is the code I use to Iterate through the controls to find the checkbox:
Public Function IterateControls(ByVal parent As Control) As String<br />
Dim id As String = ""<br />
For Each child As Control In parent.Controls<br />
If child.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBox") Then<br />
Dim clientid As Integer = child.ClientID.IndexOf("chk")<br />
Dim cid As String = child.ClientID<br />
Dim chk As CheckBox = CType(child, CheckBox)<br />
'**************************************<br />
'THIS RETURNS FALSE EVEN IF CHECKED<br />
'************************************** <br />
If chk.Checked = True Then<br />
'get id of this control<br />
If id = "" Then<br />
id = chk.ID<br />
Else<br />
'already populated<br />
'they checked one too many<br />
'now warn them<br />
Dim lblwarn As Label = CType(Page.FindControl("lblWarning"), Label)<br />
lblwarn.Text = "You can only select ONE (1) Asset at a time!"<br />
lblwarn.ForeColor = Color.Red<br />
chk.Checked = False<br />
Return "-1"<br />
End If<br />
<br />
End If<br />
End If<br />
If child.HasControls Then<br />
IterateControls(child)<br />
End If<br />
Next<br />
Return id<br />
End Function
Anyone have any clue if I am able to capture a value even though there is no postback happening?
VB or C# examples would be appreciated. Thanks
Steve Welborn
Software Engineer
BitWise Solutions
|
|
|
|
|
i can't understand your question clearly but i think your anwser is :
you must first set Autopostback property of the checkbox to the true and then work with
checkedchanged event like this code:
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (CheckBox1.Checked)
Response.Write("checked");
else
Response.Write("unchecked");
}
|
|
|
|
|
Thanks for the time and reply maryamf.
The problem with this is that I cant have it postback when the user clicks the checkbox. All validation will happen when the client clicks the 'continue' button. I had it working perfectly with the autopostback, however they thought it was distracting having it refresh on each click. And I agree if there are on dialup or something.
So my question was mainly in the validation of the page, via the continue button. I have to Iterate through the controls and find the checked one. However, this needs to be done without postback when user clicks checkboxs. Anyway to get the values of the controls this way?
Hope that made sense.
Steve Welborn
Software Engineer
BitWise Solutions
|
|
|
|
|
Javascript, and go ask in the ASP.NET forum
|
|
|
|
|
thanks for the reply leppie, unfortunatly javascript wont do it either. This needs to be server side because the values I get from the id of the checked checkbox will be used to gather the data on the next page.
I guess to ask it a different way: Can I get the correct value of a checkbox without posting back? What needs to change in the code above in order for this to happen? I can't set the AutoPostBack to true because of the refresh. This event I created takes the refresh away but now I cannot grab the value with the current code.
Come to think of it, I might just forget about doing it the event way and just do all validation in the Continue buttons click event...not sure what client would say but I know it works.
Thanks again leppie for the time.
Steve Welborn
Software Engineer
BitWise Solutions
|
|
|
|
|
hi ,
When I click on my textbox , the cursor always appear at the top of textbox.
i dont want the cursor appear
How can I disable the cursor?
|
|
|
|
|
Disable the textbox.
---
b { font-weight: normal; }
|
|
|
|
|
sorry i didnt understand ,
in my textbox , i draw square using pen class at the top of textbox and later when i click to the textbox , cursor appear so square is damaged
how can i correct this
|
|
|
|
|
If you want a textbox without a cursor, you have to make it non-editable. That you do by disabling the textbox.
If you want to draw on top of a control, you have to do that in the paint event, or whatever you draw will be drawn over whenever the control is updated.
---
b { font-weight: normal; }
|
|
|
|
|
Hey again :P
So I have a XML with DataSet in it, in the DataSet I have 2 DataTables, in each DataTable I have a Uniqe ID, and I did to this row, auto-inc, and don't allow DBNull.
So when I try to do NewRow(), and add it without setting the ID column, it throws an Exception DataColumn 'ID' can't allow DBNull.
So how can I do it as UNIQE ID? do I need to allow DBNull?
|
|
|
|
|
Hi,
i am using tableadapters to insert into 2 different tables the insert methods are in transaction. The first insert must return a value for the second insert. both inserts works just fine if the execution mode of the first tableadapter is nonquery(it doesn't return the @@IDENTITY I need) and if i remove the neccessary forein key in the second table but when i change it to scalar(to get the @@IDENTITY neccessary) it returns the following error. "ExecuteScalar requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized.". can anyone please help.
|
|
|
|
|