407 Posted Topics
Re: To reference the current Thread, you [b]could[/b] use [icode]Thread.CurrentThread.Suspend();[/icode]. The Suspend() method is obsolete however, what are you trying to achieve? | |
Re: [URL="http://en.wikipedia.org/wiki/OSI_model"]http://en.wikipedia.org/wiki/OSI_model[/URL] | |
Re: That statement will not return true for 5, for two reasons. digit would not be greater than 5, it would be equal, and 5 mod 5 equals 0. Both would be false. I don't really understand why you are performing the checks: [code=c++]if((digit%2) !=0 && (digit%3) !=0){ if((digit > 5) … | |
Re: Probably not your issue, but why are you using double for [icode]ss[/icode]. You should never really be checking a double with the == operator (unless checking for 0 I suppose). Floating point numbers are prone to small rounding errors. | |
Re: You started out right with [icode]if(bottomA < topB)[/icode]. The proceeding three if statements would not give you the desired result though. You need to compare left to right, and top to bottom. For instance: [code=C++] if(bottomA < topB) return false; if(bottomB < topA) return false; if(rightA < leftB) return false; … | |
Re: You need to go through a Java tutorial. Couple things from a glance: Each class/interface needs to defined in its own JAVA file, with the same name. For instance, SaturnSL1 must be in a file called SaturnSL1.java. You should be declaring the ParkingGarage class outside of the main method(). | |
Re: Both the 5 and 9 literals are integer, therefore the result will be an integer (not rounded; the decimal value is simply removed). You can explicitly declare them as double values by entering then as 5.0 and 9.0 respectively. You may want to have a look at "Section 7.3 Operators" … | |
Re: while loops only loop as long as the expression evaluates to true. So once it checks the value, and its false it continues on. This would work if you wanted it to continuously show "TEST". [code=C#] while(true) if(timerdone) MessageBox.Show("TEST"); [/code] Or if you only wanted it to show once: [code=C#] … | |
Re: You could use the SendInputs() function in the WinAPI. This function does not target particular windows however. First thing you'll need is structure definitions: [code=c#] struct INPUT { public uint type; public MOUSEINPUT mi; } struct MOUSEINPUT { public int dx; public int dy; public uint mouseData; public uint dwFlags; … | |
Re: The only reason you are able to use the default .NET controls, is since [url]http://schemas.microsoft.com/winfx/2006/xaml/presentation[/url] is declared as the default namespace. Otherwise you have to explicitly state a namespace alias; for instance, x:Key. Since VisualStateManager is not included in .NET 3.5, you'll have to add a reference to it. I … | |
Re: What farooqaaa said is correct of course. But, if you want to call the Click event of a control, without knowing which method is handling the event (e.g. event handler was changed), you have to inherit the control and expose the OnClick() method. For example: [code=C#]public class MyButton : Button … | |
Re: [code=C#]txtBox.Text[6] == 'm';[/code] That should work for you. If you are checking for numbers as well, you can iterate through the characters in the string (returned by the TextBox.Text property) and use char.IsNumber(). | |
Re: If your using Visual Studio, have you tried [B]Rebuild Solution[/B] in the [B]Build[/B] menu? It is possible that the IDE thinks the executable is newer than the source code. I know when building VC++ in Visual Studio, it gives you the option to run the previous successful build, if there … | |
Re: In the Main() method, put something like this: [code=C#]if (DateTime.Now >= new DateTime(2011, 8, 20) Environment.Exit(0);[/code] This says that, on or after August 8, 2011 it will just terminate the program. Note that this will, of course, be easy to bypass by changing the system time. | |
Re: Does the x'd out user folder have any non-alphanumeric or non-whitespace characters? | |
Re: You need to Windows API to work with these functions, and #include "Windows.h". The reference for these functions is located [URL="http://msdn.microsoft.com/en-us/library/ff468802(v=VS.85).aspx"]here[/URL]. Be sure to check the return value of OpenClipboard(). If it returns a zero (false) it failed, otherwise, if it returns a non-zero (true) it succeeded. If it returns … | |
Re: Did you have a specific question? Or have you made an attempt and can't get something working right? People here will not do your homework for you. | |
Re: Your question is a little vague on details, but you could initialize a new TimeSpan: [code=C#]TimeSpan span = new TimeSpan();[/code] Then iterate through your list of hours and add them as a new TimeSpan: [code=C#]span += new TimeSpan(hours, minutes, seconds);[/code] I don't understand what to are trying to get at … | |
Re: Note that you can use fall-through for empty case's: [code=C#]switch(i) { case 0: case 1: ... break; case 2: ... break; }[/code] This is occasionally useful. | |
Re: You can define whatever you like. If you access the file as a binary file, you can use 256 values with a single byte. Or you can use two bytes, this would 65536 values. Some things you may want to consider though: - You'll need at least two layers for … | |
![]() | Re: When working with Object properties, you can determine the type using something like: [code=C#]System.Diagnostics.Debug.WriteLine(comboBox1.SelectedItem.GetType());[/code] Assuming you are using an IDE. Otherwise you can just show it in a MessageBox. In this case it is returning a KeyValuePair<string, object>, so you can just cast it and check the Key property: [code=C#]KeyValuePair<string, … |
Re: Right-click on your project in solution explorer and click Properties. Under Configuration Properties --> Common Language Runtime Support, ensure it is set to [B]No Common Language Runtime Support[/B]. When creating a new project, under Visual C++, select Win32 and then select either [B]Win32 Console Application[/B] or [B]Win32 Project[/B]. Just to … | |
Re: Request to Send (RTS) is used to signal a devices intention to send data. Without it the connected device may refuse to receive data. For modems, Data Terminal Ready (DTR) is used to tell a modem that it wants to dial out, and drops the signal to low to drop … | |
Re: Your should add an initializer for base8; if x is < 10 then base8 is never assigned and will cause problems with the result. In addition, it looks like you can't go beyond certain number (i.e. 123 does not work). In either case, I think you're over complicating the issue. … | |
Re: Could you post your code? I'm having trouble understanding what your question is. | |
Re: When you compile the source code, everything gets translated to machine code, and everything ends up being referenced by a memory address. In addition, the compiler will likely optimize your code, and will not maintain any 1 to 1 relation to the source code. The idea of a line number … | |
Re: Assuming you are using an array of pointers (you could easily modify if you are storing the structures themselves): [code=C++]int count = 0; for(int i = 0; i < size; i++) if (teams[i]->progress) count++; Team **teamsSubset = new Team*[count]; for(int i = 0, i2 = 0; i < size; i++) … | |
Re: For [icode]b &= (byte) ~a;[/icode], the compiler will check this conversion since a is a constant, and it is certain what the value will be. Since bitwise operations return int's (doesn't seem right to me), it will evaluate ~a as an int, which would evaluate to -9. I don't think … | |
Re: Do you have Visual Studio 2010 installed? I don't believe any previous versions ever added support for 4.0. If so, just open the solution with VS2010, and use the conversion wizard. | |
Re: Form has a public Dispose() method. Why are you trying to cast between the two types? Assuming that both classes derive from Form, HD.MainMenu and HD.NewBookEntry are both ancestors of Form, and have common variables/methods from Form. However, they define their own variables/methods, therefore they lack a commonality between them. | |
Re: It is because of the [icode]while(y<=num)[/icode] statement. When your iteration, where x = 21 and y = 34, is complete: it checks if y is <= num (which it is), so it continues executing. If you changed it to [icode]while(y<num)[/icode] it would stop at 34. ![]() | |
Re: You can download the express editions. It looks like Microsoft no longer directly links to any of the downloads on their site anymore, but you can still link to them directly. Note that I have [b]not[/b] tested any of these links: [URL="http://apdubey.blogspot.com/2009/04/microsoft-visual-studio-2005-express.html"]http://apdubey.blogspot.com/2009/04/microsoft-visual-studio-2005-express.html[/URL] | |
Re: The DataSet class does offer direct serialization to/from XML files, however I'm assuming your DataSet doesn't necessarily correlate to your XML schema. So, take a look at the [URL="http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx"]XmlDocument[/URL] class. Basically you can create XML elements and attributes using the XmlDocument's Create...() methods, than use AppendChild() on the appropriate object … | |
Re: You shouldn't be converting the float variable to a string. This will not allow the proper formatting: [code=C#]double A = 0.532492829839; string.Format("{0:0.00}%", A * 100.0);[/code] | |
Re: I would recommend you use the [URL="http://download.oracle.com/javase/1.4.2/docs/api/java/util/Random.html"]Random[/URL] class in these exercises. Specifically, look at the [icode]nextInt(int n)[/icode] method when you require integers. Calling the default Random() constructor should generate a suitable seed value for your purposes. For your first question, Math.random() returns values in the range [0,1). This means that … | |
Re: Is the background image being covered by the highlighted border? If so, you'll probably have to override a Renderer class, and wrap the default ToolStripRenderer to achieve this. See [URL="http://social.msdn.microsoft.com/Forums/en/winforms/thread/bc5a2554-6b38-4f4a-bb9a-7fbf4011eef6"]this thread[/URL]. It's been a while since I've done much with WinForms, but I believe this is quite an involved process. … | |
Re: You are adding the input value to num; then checking num. Therefore if you entered 5, 6, 7, 0. num would equal 18 when you checked it against 0. Try something like this: [code=C#]... int n = int.Parse(Console.ReadLine()); if(n == 0) break; num += n; ...[/code] Also, note that I … | |
Re: Arrays are initialized when they have a length of 0. They may not contain any values, however they do store the length and allow you to reference it. If you attempt to reference the length of a null reference, you will get an exception. It can be useful when you … | |
Re: [icode](a - (a * b))[/icode], where a = 19.99 and b = 0.2, equals 15.992. It you multiply it by 12, you get 191.904, which rounds to 191.90 on line 27. You would have to round the calculation [icode](a - (a * b))[/icode] before multiplying it by c to achieve … | |
Re: You can never be certain of rounding errors. For instance try running the following code: [code=C#]Console.WriteLine("{0:G17}", 0.72 + 0.11 + 0.06 + 0.11);[/code] On my system, this returns 0.99999999999999989. Note that this may be different for your system, which leads to your second question. Consistency cannot be guaranteed across different … | |
Re: You should be able to do something like this: [code=C++]char **b_array; b_array = new char*[MAXPATHLEN]; for(int i = 0; i < MAXPATHLEN; i++) b_array[i] = new char[numFtrs]; char ***b_array_ptr; b_array_ptr = &b_array;[/code] I am certain there is some shortcut for this, but I don't have time to look around right … | |
Re: Does it need to be efficient? If O(n2) is acceptable, you could just initialize an int array of the same size, then store the number of following characters that are equal. Then use the index of the largest int value to locate your maximum occurring character. | |
Re: Events can only be raised from the class that declared them (even derived class' cannot invoke them). Luckily WPF/Forms controls implement protected methods to allow derived classes to do this. Just derive from the Button class, and call OnClick(), for example: [code=C#]public MyButton : Button { public void SimulateClick() { … | |
Re: I believe when you create the new Chart, it becomes the new ActiveSheet. Therefore you are trying to retrieve a Range from the Chart. Try creating the Chart after getting the Range. | |
Re: For your first pattern, you would require something like: [icode]\{(\-?[0-9]+\.[0-9]+,)*(\-?[0-9]+\.[0-9]+)\}[/icode] Note that I made quite a few big assumptions for this: - Cannot be empty ("{}") - Cannot exclude the decimal or numbers before/after (".9", "9." or "9" would be invalid"). - Cannot start with a + sign. Take a … | |
Re: Take a look at the [URL="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.aspx"]System.Data.SqlClient[/URL] namespace, and search for some tutorials on using SQL with C#. There are plenty around. | |
Re: You can also use the AcceptButton property of the Form. This will however, capture the Enter key from any control on the Form. But, this generates the button's Click event, a mouse click or enter key can be handled in the same method. | |
Re: Look at the [URL="http://msdn.microsoft.com/en-us/library/system.console.aspx"]Console[/URL] class. You can use a combination of the Write(), WriteLine(), Read(), ReadKey() and ReadLine() methods. | |
Re: You'll want to take a look at the [URL="http://msdn.microsoft.com/en-us/library/y3y47afh.aspx"]System.Xml[/URL] namespace. As a starting point, you can call [icode]XmlDocument.Load(...)[/icode], and work from the XmlDocument object created. | |
Re: You could handle the [icode]RowsAdded[/icode] and [icode]RowsRemoved[/icode] events, then implement something like this: [code=C#]private void dataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs args) { textBox.Text = ((DataGridView)sender).Rows.Count; } private void dataGridView_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs args) { textBox.Text = ((DataGridView)sender).Rows.Count; }[/code] |
The End.