Jump to content
Xtreme .Net Talk

Bucky

*Experts*
  • Posts

    803
  • Joined

  • Last visited

Everything posted by Bucky

  1. Ah, another satisfied customer! You can send checks or money orders to Bucky, PO box- *looks off stage* What? Oh, I guess I can't do that. :) It's good to hear a success story among a sea of code problems and questions. Congrats.
  2. Yes, that's correct.
  3. Yes, assign it to the Session variable like you're currently doing. Then, to access it from a page, just cast it to the correct type. For example: Dim myCustObj As MyCustomClassObject myCustObj = DirectCast(Session("UserObject"), MyCustomClassObject) ' Here you manipulate myCustObj
  4. This is a long shot, but perhaps the localization settings on your computer actually recognize the "." character as a thousands- separator, and use "," for a decimal point, like they do in the UK. If this is the case, you also have to change any code containg in "or" to "our", and add a few "blimey"s in your comments. ;) (Not really)
  5. In writing code to handle the listening and connection-accepting of a Socket instance, I've run into a snag after calling BeginAccept. After calling BeginAccept, I want to be able to cancel the calling of my callback function and essentially stop the Socket from listening before it actually receives a connection request. When a connection request does come, the Socket accepts it, receives from it, and closes it fine, but I'd like to be able to stop the Socket from listening before a connection is requested. GavinO suggested a very creative kludge that invoves creating a new Socket and connecting with listening one so that the connection would be made (behind the scenes) and then successfully closed right away. Needless to say, I'm hoping there's a more elegant way. :) Oh, and this is the code I'm using to start the accept callback: IAsyncResult beginAcceptResult; beginAcceptResult = listenSocket.BeginAccept(new AsyncCallback(ListenCallback), null); Thanks.
  6. Use the Convert.ToDouble() method, or the Double.Parse() method, similar to what pendragon mentioned, to convert the text, which is a string, into a number that VB can work with correctly. totalCostIn.Text = Convert.ToDouble(txtCostIn.Text) * Convert.ToDouble(txtQuantityIn.Text)
  7. You can't turn an empty string into a number. Add a check before doing the multiplication to check the length of the text. Shown here is one sub, but the change needs to be applied to both. It'd be easier if you stuck all the code into a subroutine, called MultiplyValues or somesuch. Then just call this method within each event handler, since they both do the same thing. Or you could have the event handler handle the TextChanged event of both subs by putting a comma between the event names. Private Sub txtCostIn_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtCostIn.TextChanged If Not IsNumeric(txtCostIn.Text) And Len(txtCostIn.Text) > 0 Then MessageBox.Show("") Else If txtCostIn.Text = "" Or txtQuantityIn.Text = "" Then ' If either value is empty, then substitue in 0 for the answer totalCostIn.Text = "0" Else totalCostIn.Text = txtCostIn.Text * txtQuantityIn.Text ' Otherwise, multiply End If End If End Sub
  8. If you're coding in C#, you can also compare it to the escape character "\n".
  9. If you wanted to include files in the final application, such as images or data files, but didn't want them as actual files on the computer, you can have them compiled right into the final app. The code that Diablicolic posted allows you to create a stream from that compiled data (a resource) and access it at runtime. As an example for what you could do with the resource, he saves it to the desktop.
  10. Eek :eek:. LineInput is one of the old VB6 methods ported over to .NET, and should thus be avoided. Instead, create a FileStream of the text file, and use the StreamReader to read it line by line, or by blocks of text. The Stream has a Length property which will tell you the total length of the file, and a Position property to show where in the stream you are reading from. A little bit of simple math will get you a percentage of the file read, which you can apply to the ProgressBar. Read up on it [mshelp=ms-help://MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconreadingtextfromfile.htm]here[/mshelp].
  11. If you pass the same directory to both parameters of the method, then sure, the file is being renamed. Think of it as being moved to a different place within the folder. This method can also move files do different directories, of course, but if you pass the same directory structure to both parameters, the method will simply rename the file.
  12. Well do like kahlua001 mentioned: in the onSubmit event of the form, disable all the buttons. That way you don't need to keep track of which button was clicked. The button you clicked will still be posted back to the server correctly.
  13. Well the conversion functions mentioned above are not actually in the framework, they're VB-specific keywords. As a general rule, don't use any VB6 functions. Anything with the same name as VB6 is probably part of the "Visual Basic Run-Time Library Members", which you should stay away from. Yes, it takes some getting used to, but yes, it helps in the end.
  14. Come to think of it, that's just what we need: drunk, co-ed pilots getting busy the cockpit. There's safety for ya. ;) Just hope they don't push the intercom button. Actually, I think Dave Barry has it covered:
  15. Can you just disable them all?
  16. Don't use the old conversion methods of VB6, ones such as CLng, CStr, CDbl, etc. Instead, use the shared methods of the Convert class. MessageBox.Show(Convert.ToInt32(True).ToString())
  17. Sure. Fill the entire background with some color that wouldn't actually be used in the picture (I like to use lime green). Then do all your painting and call the MakeTransparent() method of the Bitmap, passing the color you filled the background with.
  18. Are you perhaps filling the region with a brush after drawing the border? Because the pen's width straddles the actual border of the Region, it's possible that the fill is overlapping the pen. If so, just do the filling before drawing the border.
  19. When there is more than one equals comparison operator on a single line, the values of each are evaluated from left to right. So, in this (poor) example, first it would compare (e.KeyState And 1) and 0. It takes this value and compares it to False, and returns another boolean value (0 or 1). Goodness knows why there are multiple =s on that line; the line is checking to see if (e.KeyState And 1) is NOT equal to 0, which the <> operator serves a purpose for: checkBoxUnShift.Checked = (e.KeyState And 1) <> 0
  20. [mshelp=ms-help://MS.MSDNQTR.2003FEB.1033/vbcon/html/vbtskcreatingeventhandlers.htm]Creating Event Handlers on the Windows Forms Designer[/mshelp] Follow those example to put the code for multiplying the TextBoxes inside the TextChanged event of each TextBox.
  21. I'm not sure I understand... there is a DrawEllipse method of a graphics object, which you can easily use to draw a circle on a small bitmap. Bitmap bmp = new Bitmap(16, 16); Graphics g = Graphics.FromImage(bmp); g.DrawEllipse(Pens.Black, 1, 1, 14, 14); Does that work for you?
  22. As far as I know, no. But if anyone can disprove me, please go right ahead.
  23. Since C# is based on C++, if C++ had the statement then C# definitely would. So again, the answer's no.
  24. Oh crap, my mistake... sorry 'bout that, but I think you get the idea.
  25. It's also worth mentioning that the Framework methods are platform-independent, which is one of the goals and strengths of the entire Framework. This is why the Framework has, in its short life so far, already been ported to Linux and Windows CE devices. So, try to stay safe and learn the new ways of the .NET.
×
×
  • Create New...