
Bucky
*Experts*
-
Posts
803 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by Bucky
-
Yes, this is true. It will save time and resources by loading the object just once, especially if you are setting and accessing multiple properties. This was also true of VB6. Unfortunately, this is one mighty handy feature that C# lacks.
-
You don't. Instead, create mutliple overloads of the same function, with the optional parameters missing for some. First create the main function which does all the calculating in it, and it has all the parameters you're going to use. Then write overloads that have less parameters and pass default values to the parameters that are missing. For example: public string FunctionName() { return FunctionName("default value 1", "default value 2"); } public string FunctionName(string parameter1) { return FunctionName(parameter1, "default value 2"); } public string FunctionName(string parameter2) { return FunctionName("default value 1", parameter2); } public string FunctionName(string parameter1, string parameter2) { // Do the actual processing of the parameter here }
-
Oh, I see. Put the code for doing the multiplying in a subroutine. Then, in the Changed event handlers of both TextBoxes 1 and 2, call that subroutine. Or, if you want the sub to be called when the boxes lose focus, then place the calls to the sub inside the Validated event.
-
If you don't want it to multiply the values automatically, then don't put the code for multiplying in the TextBoxes' change event handlers. Instead, put the code in a Button's Click event handler, or wherever you want to multiply the values.
-
Hey, the time wasn't wasted; you found a solution, didn't you? That's all that matters. :) Glad you figured it out; I wouldn't have thought to try that.
-
I'm guessing that you're calling addtodropdown() in the Page's Load event, right? If this is the case, you need to check the IsPostBack property, and only populate the dropdown list if IsPostBack is false. Otherwise, every time the page loads the dropdown list is populated and the original values are erased. Now SelectedValue should return the correct value. // in Page_Load: if (!IsPostBack) addtodropdown();
-
Ah yes, good catch; I had forgotten about the SELECT part in there. In that case, determine the length of the beginning SELECT statement beforehand, and compare the string's length to that instead of 0.
-
Well, because different fields have different names and formats, you could just create a bunch of If statatements to add each thing to the SQL statement before executing it. You use the AND operator to stick more than one condition together. Here's a little function that checks if the SQL string is empty. If it is, then you don't need to stick an AND in there. If it already contains a condition, then you will need to include an AND. private string AddCondition(string sql, string condition) { if (sql.Length == 0) return sql + " " + condition; else return sql + " AND " + condition; } And here's the code that would compile the SQL statement: string sql; if (birthdateText.Text != "") sql = AddCondition(sql, string.Format("Birthdate = '{0}'", birthdateText.Text); if (firstnameText.Text != "") sql = AddCondition(sql, string.Format("FirstName = '{0}'", firstnameText.Text); // And so on, for each input control
-
How are you accessing the database? If the data is loaded into a DataSet object, you can use the Select() method of the DataTable to return the rows. If you're using some type of DataAdapter, then you will need to compile a SQL statement to select the rows.
-
This is difficult to do. Each IM service has its own protocol for communicating between the servers and the clients. As I recall, the AIM protocol isn't even readable text most of the time. I suggest you do research on the protocols each chat medium uses before diving into them. If you're going to incorporate IRC into your program as well, I suggest you start that. Also, MSN Messenger has a reference you can add to your project to easily use it.
-
Disable anti-alaised painting in Paint event
Bucky
replied to Bucky
's topic in Graphics and Multimedia
No such luck. In fact, I just realized that I cannot even change the properties of the Graphics object. Whenever I assign a value, the property doesn't even change to the value I try to assign to it. I had forgotten that e.Graphics is a read-only object. So, I take it I need to do the painting somewhere else, or find a way to alter the e.Graphics object. Which of these should I do, and how? -
I'm trying to resize an image and paint it in a PictureBox in its Paint event, but the picture is supposed to be drawn regularly, not anti-aliased. Setting the SmoothingMode property to None has no effect; it's drawn fine, but it is still anti-aliased. How can I have it painted regularly, but still scaled up? Here's what I'm using ATM: private void pic_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Graphics g = e.Graphics; g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; Rectangle dest = new Rectangle(xOffset * scale * -1, yOffset * scale * -1, bmp.Width * scale, bmp.Height * scale); // these are all form-level variables g.DrawImage(bmp, dest); // bmp is a form-level variable } Thanks.
-
The AcitveX references are listed under the COM tab in the References dialog. If you're looking to use DirectX in VB.NET, however, I'd reccomend you use DirectX 9.
-
Do you mean undock the toolbars? Just drag them to the center of the screen to undock them. Some toolbars are put in tabs, at which point you drag the tab to the screen center.
-
Oh, heh. You don't need to serialize it this way. The DataSet can serialize the data itself by using the WriteXml method. That's all you need to do, just call dsUsers.WriteXml() with a file path.
-
I don't understand, you did what?
-
Also Property: Public Property Blah() As String
-
It's a class that is a collection of your address book contacts. So, for example, you first create a class that stores all the address information, like so: Public Class Contact ' Private members of the class Private m_FirstName As String Private m_LastName As String ' Public properties that are saved in the XML file Public Property FirstName() As String Get Return m_FirstName End Get Set(Value As String) m_FirstName = Value End Set End Property Public Property LastName() As String Get Return m_LastName End Get Set(Value As String) m_LastName = Value End Set End Property End Class Then make a collection, add some contacts, and serialize it: Dim contacts As New ArrayList() Dim person As New Contact() person.FirstName = "Bucky" person.LastName = "Fuller" contacts.Add(person) Now the contacts variable is the substitution for MySerializableClass. You don't need to initialize it again, because it's already done in the above code. Just serialize it.
-
There's no such thing as an "If loop", but yes, you can exit any type of loop by using Exit (name of loop).
-
MySerializableClass needs to be the class that has a collection of all your contacts. As for the other squiggly lines, you need to import the namespaces System.IO and System.Xml.Serialization
-
A module provides a way to declare public members that can be seen throughout the entire project (also known as global). While this may seem convenient, it's disorganized and goes against the concepts of OOP. You should never have to use a module. Instead, create a class that has static (Shared in VB) members. Also, modules do not have instances like classes do; they are not initialized or destroyed, and their variables keep their vaules for the duration of the app's execution.
-
Perhaps, since Longhorn is based largely on .NET, .NET languages and applications may see a performance boost and thus make them more feasable for commercial applications. Is this a correct assumption to make?
-
I'm a little bit of a newb to .NET, but know 6.0...
Bucky
replied to griffyboy0's topic in Windows Forms
If that's the case, then the button click event handler probably isn't being called. Make sure that the event handler has the correct signature and it has the Handles statement. For example, if the button was called Button1, it'd look like this: Private Sub Button1_Click(Sender As Object, e As EventArgs) Handles Button1.Click Dim MyNewForm As New FormWiz MyNewForm.Show() End Sub