Jump to content
Xtreme .Net Talk

Bucky

*Experts*
  • Posts

    803
  • Joined

  • Last visited

Everything posted by Bucky

  1. Create a batch file to do all that work for you. Also, instead of /reference: you can just use /r:
  2. Subroutines have a "Handles" statement that is placed after the parameter declarations. Events can be comma-delimited so that one sub handles many events. Like this: Public Sub Labels_Click(sender As Object, e As EventArgs) Handles Label1.Click, Label2.Click, Label3.Click ' Event handler here End Sub Of course, if you don't want to type out all the event handlers, place all the Label controls in a container (a frame or a panel) and on the Form's load event add the handler for all the controls. Dim ctl As Control For Each ctl in Panel1.Controls AddHandler ctl.Click, AddressOf Labels_Click Next
  3. Nice work! The controls for moving the blocks is as I expected them to be. Now, for a few suggestions: It helps if all pieces of the same type are the same color. It's much easier to notice patterns and it helps trigger recognition of the piece when it first shows up. Try to match the original Tetris colors, if you can. :) You could add so much more to the game if you drew out the shapes instead of using Panel controls. Not only do they provide some overhead for creating and using, but they aren't really that pretty to look at. You have all the code down for positioning the squares and such, so it should be easy to adapt to drawing shaded rectangles or images to make the game look nicer. There's also a little flickering when the panels move, which would be eliminated if the drawing was done correctly. There are some repetitive code sections that could be greatly reduced in size, such as lines 757 - 839. You could shorten that by using some math: For i = 0 To 179 If found(i) = True Then count += 1 If count = 10 Then lines(17 - (i \ 10)) = True count = 0 End If Else level -= 25 count = 0 i = (i \ 10) * 10 + 9 End If Next i Now that's a lot shorter, eh? The first replacement integer divides i by 10 to get a whole number, then subtracts that from 17 because that's the highest index in the lines array. The second part rounds i down to the nearest multiple of ten, then adds 9. Compare it to your code, and the pattern will make sense. Keep up the good work.
  4. There most certainly is a cleaner way: Dim filename As String = System.IO.Path.GetFileName("c:\whatever.txt")
  5. I don't know what AVR.NET is, but in Windows Forms applications (C# included) you can call Application.DoEvents() to pause and let Windows process some messages.
  6. Lemme clear a few things up here... Every class in the .NET Framework inherits from the most basic class of all, the Object. The Object has a ToString() method, so therefore every class and variable has a ToString() method. You can use this to get a string value. To convert between other value types, you use the System.Convert class (Convert.ToInt32(), Convert.ToString() if you want, etc.), and you use DirectCast() to cast between objects. The new version of MsgBox is MessageBox.Show().
  7. Your lhWnd variable is of the Long type. The API declaration for SendMessage specifies the first parameter as an IntPtr type. You need to either: a.) Change lhWnd's Dim to the IntPtr type, and change the declaration of FindWindow to return an IntPtr (this is more proper, since an hWnd is more specific as an IntPtr than just an Integer), Or: b.) Change lhWnd to an Integer type, and change the declaration of SendMessage to have the first parameter (hWnd) be an Integer. Integers and IntPtrs are interchangeable for passing between .NET apps and Windows APIs, but within the app itself the types need to match up. You should also declare r as an Integer.
  8. Put your code for populating the textboxes inside a subroutine. Then just call this sub at the beginning of your For-loop code block.
  9. Check out wyrd's card games for guidance on shuffling your cards. The Deck class has a Shuffle method that you can look at. It basically just loops through every card and swaps the current card in the loop with a random one.
  10. Ah, very cool. I didn't know about those controls. (for anyone else interested, click here). To get the selected node's value, try: myNodeName = TreeView1.Nodes(TreeView1.SelectedNodeIndex).Text
  11. I'm assuming this TreeView control is a 3rd-party component, because it's not in the Framework anywhere. There's probably a SelectedNode and/or SelectedNodeIndex property somewhere in there that you can retrieve the value of. We can't help if we don't know the control, however, so do you have info on who makes it or a link to their site?
  12. Is this drop-down list databound, or are you populating it dynamically? If this is so, then it's likely that in the Page_Load event you're re-binding the control again. Whenever you DataBind a list, its selected index is set back to -1. You need to insure that the page is not being posted back from the client. So, in Page_Load: if (!this.IsPostBack) { // If it's NOT postback // Bind your control(s) } You also shouldn't have to use a huge block of Ifs to set the label's text, just set it to the value of the selected item (once you get the SelectedItem to return something): Label1.Text = DropDownList1.SelectedItem.Value;
  13. What you're doing in VB is the same as that C# code. The only difference is the placement of the code. You need to place your code in the InitializeComponent method of the codebehind page, not in Page_Load (as I'm assuming that's where it is ATM).
  14. Chatters needs to be a collection of some sort. Dim chatters As New ArrayList() Dim c1 As New Chatter() Dim c2 As New Chatter() c1.Name = "blah" c2.Name = "whatever" chatters.Add(c1) chatters.Add(c2) ' Then you can serialize the chatters class
  15. Using Control.Invalidate() is much faster than using Control.Refresh() for triggering the painting.
  16. In that case, you'll have to subclass the window of the control and block all messages that Windows sends that tell the control to paint itself (such as WM_PAINT). Then you have to paint the control yourself. Again, this requires a good understanding of subclassing.
  17. Instead of doing the initialization inside the constructor of the base class, create a protected or public method in the base class that does the initialization, and then you can call it in both the regular constructor and the inheritor's constructor. class Inherit : c1 { Inherit() { base.InitClass("whatever"); } } class c1 : UserControl { public c1(){} public c1(string argument) { InitClass(argument); } protected void InitClass(string argument) { // Initialize the class with the argument in this sub } } Does this solve your problem?
  18. Check out these articles on EliteVB (notice that they are in VB6), along with the [mshelp=ms-help://MS.MSDNQTR.2003FEB.1033/Cpqstart/html/cpsmpnetsamples-howtowindowsforms.htm#cpsmpOwnerDrawListBoxSample]MSDN documentation[/mshelp] which contains examples for ownerdrawing a listbox.
  19. Bucky

    msgbox

    You can add a little bit of JavaScript to a button that pops up a dialog with OK or Cancel. If the user clicks OK, the code for the button executes. Otherwise, nothing happens. This code can go in the Page.Load event or any code that executes before the page finished loading, where myButton is the name of the button control: myButton.Attributes.Add("onClick", "java[b][/b]script:return confirm('Would you like to exit?')"; Anyway, is that what you're looking for? [edit]To avoid confusion, I've fixed the 'javascript' bit. -VolteFace[/edit]
  20. If you're looking to create skins for an app, you will need to learn how to ownerdraw, that is, to intercept Windows' messages to paint the window and to paint it yourself. This is accomplished through subclassing. I suggest you learn the basics of subclassing before going further. XML does not have anything to do with drawing the skins, but it can be used as a way to store the information for the skins (images, colors, etc.) for creating and transferring them.
  21. You can most certainly make DLL's in VB6 and VB.NET. In VB6, the DLLs utilize COM, so any language that supports COM (VB6, .NET languages, C++, etc.) can use VB6 DLLs. .NET languages, however, (perhaps with the exception of C++.NET, I'm not sure) compile to special DLLs that only other .NET applications can import.
  22. I was just curious... is it possible to view the console output (calls to Console.WriteLine() and such) in a compiled Windows Forms application outside the VS.NET IDE? I know I could just write to a text file for output, but I was wondering about this method.
  23. I believe I see the problem. The only child node of fDom is the "game" node; thus, the "game/paramDefault" node is not a child of the fDom document, it's a child of the "game" node. You need to call the ReplaceChild of the "game" node instead of the ReplaceChild method of the main document. 'Here's the error... fDom.SelectSingleNode("game").ReplaceChild(paramDefault, oldParam)
  24. [mshelp=ms-help://MS.MSDNQTR.2003FEB.1033/csref/html/vclrfIntroductionToAttributes.htm]Here we go[/mshelp]. In VB.NET, attributes are put inside < and > characters. There is also a typo in your first sub, EchoServer; it should be System.Diagnostics.DebuggerStepThroughAttribute()
  25. That is correct. Because the Internet was designed as a stateless environment, there is no uniform way (between HTML, PHP, ASP, etc.) to maintain state (except for maybe cookies). If the data in "Fred" is not security-concious, you could also pass the value into the QueryStrings of the next page. Then, when people copied and pasted the URL, the state would be maintained. You don't want to do this if the data is too large. For example: /mypage.aspx?Fred=woohoo&Ethel=yeahbaby You can use cookies if you're storing the data for a long time, and want to keep it when the user returns to the site. So it's up to you! Session variables, cookies, and query strings all have different qualities, so choose wisely, grasshopper. :) [edit]Click me! <- Robby indirectly solves all your confusion[/edit]
×
×
  • Create New...