Jump to content
Xtreme .Net Talk

Derek Stone

*Gurus*
  • Posts

    1910
  • Joined

  • Last visited

Everything posted by Derek Stone

  1. You can still import System.Drawing.Printing in a web application. Of course all that's going to do for you is enumerate the printers on the server, which is of little use in my opinion.
  2. Don't bother redeclaring it everytime. Call the object's Clear method instead.ArrayList.Clear()
  3. [mshelp]ms-help://MS.VSCC/MS.MSDNVS/vbcn7/html/vbconShadowing.htm[/mshelp]
  4. The use of modules in any object-oriented application is a poor decision. The reason(s) (God forbid there be more than one) why Microsoft included the ability to use modules in .NET blows my mind, and I prefer not to think about it. Instead, look towards using shared (static) members of a class. They're coded like so: Class Dog Public Shared Sub Bark() 'Dog barks End Sub 'Bark End Class 'Dog You can call the function like so: Dog.Bark() It's rather simple, as you can see.
  5. It's possible to hook certain types of messages, however some types require a standard DLL to be injected into each process at startup. This of course requires a language that can create standard DLLs, C being the most popular candidate.
  6. You might try a combination of [api]ShowWindow[/api], [api]SetWindowPos[/api] and [api]BringWindowToTop[/api], all of which are Win32 API functions. Of course using these depends on getting the handle of the window in question, which can be difficult in many situations.
  7. You'd communicate via Windows Sockets. This is the only correct method of direct communication available, and it's the method commonly used by the Windows subsystem.
  8. http://www.mysql.com/articles/dotnet/
  9. Darken.... lighten... what's the difference! ;) Thanks though, looks much better.
  10. Passing parameters to a thread is fairly easy. Take a look: http://www.xtremedotnettalk.com/showthread.php?s=&threadid=70749
  11. As it stands now you're probably launching new threads from your application's main class. Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim tThread As New Thread(AddressOf SecondaryThread) tThread.Start() End Sub Private Sub SecondaryThread() MessageBox.Show("Code executing in new thread", Application.ProductName) End Sub End Class The above snippet works just fine as long as no parameters need to be passed to the thread. In the likely event that parameters do need to be passed however the code needs to be reworked. Since methods called from a thread continue to execute on the same thread, even if they are located in a different class, we can rearrange the order of execution a bit to suit our needs. The ThreadArguments class, declared below, exposes the ThreadDelegate property that can be set to the location of the sub or function that's to be executed on a new thread. When the thread executes the Start method is passed as the sub to be placed on a new thread, which in turn passes execution along with a single parameter to our TertiaryThread function. Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim ta As New ThreadArguments() ta.Message = "Custom message" ta.ThreadDelegate = AddressOf TertiaryThread Dim tThread As New Thread(AddressOf ta.Start) tThread.Start() End Sub Delegate Sub TertiaryThreadDelegate(ByVal Message As String) Private Class ThreadArguments Public Message As String Public ThreadDelegate As TertiaryThreadDelegate Public Sub Start() ThreadDelegate(Message) End Sub End Class Private Sub TertiaryThread(ByVal Message As String) MessageBox.Show(Message, Application.ProductName) End Function End Class The concept here is to pass the execution from a sub that can't handle parameters to one that can. We initialize a new instance of the ThreadArguments class for each thread we create so that the parameter(s) we pass remains unique an isolated from all other threads. Keep in mind this code can be extended to handle multiple parameters and return values, the latter which we'll look at next. Download example application
  12. It's hard to differentiate between link text and normal text in the Lite style. If someone could darken the link color up a bit that would be great.
  13. Create a public enumeration in any of your classes, then reference it using its fully designated name: Public Class Class1 Public Enum Numbers One = 1 Two = 2 Three = 3 Four = 4 Five = 5 End Enum End Class Public Class Form1 Inherits System.Windows.Forms.Form Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load MessageBox.Show(ReturnANumber().ToString, "") End Sub Private Function ReturnANumber() As Class1.Numbers Return [b]Class1.Numbers.One[/b] End Function End Class
  14. It's not going to make any difference unless the data has the possibility of being displayed in an alternative fashion in the future, or in another application accessing the web service. For the sake of ease of upgradeability in the future, I'd advise you to return a broader data structure, instead of TreeView nodes.
  15. Dim oConnection As SqlConnection = New SqlConnection("[ Connection string ]") Dim oCommand As SqlCommand = New SqlCommand("DELETE FROM Make sure to import System.Data.SqlClient when you use this code.
  16. Set the CSS style attribute to reflect the top and left positions of the button. Button1.Attributes("style") &= "position: absolute; top: 100; left: 100;" Keep in mind this is the position of the button in its container, so to make it easier on yourself add the button to the page's control collection instead of an alternate parent element.
  17. <form id="hiddenForm" action="page.aspx" method="get"> <input type="hidden" name="answer" id="answer" value="" /> </form> <script language="JavaScript"> var answer; answer = confirm('Are you sure ....?'); document.all.hiddenForm.answer = answer; document.all.hiddenForm.submit(); </script>Of course that's off the top of my head, so it might need some tweaking.
  18. Store the value in a JavaScript variable that once filled, submits the page to itself along with the user's response in either the query string or a form field.
  19. There's little stopping you from creating a COM-callable wrapper for your .NET DLL, if a COM DLL is in fact what you're looking for.
  20. Yeah, the size needs to be bumped up to 2. I just rearranged the order of the tags to make the block valid. I didn't adjust the font, although that was one of the errors present beforehand. Also, the [code] tags don't reflect the changes made to the others. Thanks Keith, changes are appreciated. :)
  21. Try running the following at a command prompt before you hassle yourself by reinstalling the framework: Aspnet_regiis -i
  22. You need to add the .NET Framework directory to the global PATH variable in Windows. Either that, or be forced into typing out the full path to csc.exe all the time. Right click on My Computer and select Properties. Click the Advanced tab and hit the Environment Variables button. Append the location of the .NET Framework folder to the end of the PATH variable (either will do). Make sure to delimit it with a semicolon. The .NET framework path should look like the following: C:\%WINDOWSDIR%\Microsoft.NET\Framework\v1.0.3705
  23. .ToString("###,###.###############") Am I missing something? :)
  24. It hardly makes a difference what .NET language it is in. The framework allows for complete interoperability between VB and C#, along with any of the other .NET languages. You can take a DLL made in VB.NET and use it in a C# project, and vice versa.
×
×
  • Create New...