Jump to content
Xtreme .Net Talk

PlausiblyDamp

Administrators
  • Posts

    7016
  • Joined

  • Last visited

Everything posted by PlausiblyDamp

  1. try something like intbonus = Convert.ToInt32(Math.Floor(8 / 5)) not tested though so use at your own risk ;)
  2. Clicky little tutorial on these kind of things from our very own Bucky.
  3. You may find this worth a read as it covers the exact same issue.
  4. Doing the 315, 320 and 229 would get you the MCAD certification just fine, also if you are then looking at doing the MCSD certification they will all count towards that - leaving you with probaly the 316 (windows development with C#) and the 300 (solution Architecture) remaining.
  5. Just to add Sysinternals has a nice process monitor that can show number and types of garbage collections that have happened (along with a whole load of other statistics). If you really want to know how GC works then I would definately recomend reading Applied Microsoft .NET Framework Programming by Jeffery Richter, as well as being an excellent book in it's own right the chapter on memory management in .Net is the most comprehensive one I've seen so far.
  6. Not Univeristies as such but if you look at some of the Official Microsoft courses on VB.Net they frequently use constructs like CInt, MsgBox, IsNumeric (and even tell you how to use InputBox for gods sake). This kind of thing really does wind me up as not only does it not show you the .Net way but doesn't even let you know there is an alternate way.
  7. It's top of my bookmarks at work, at home and on my laptop :)
  8. Just tried it here - created a new project, set its keypreview to true and added this code Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown If e.KeyCode = Keys.Right Then MessageBox.Show("Right") End If End Sub worked just fine.
  9. Are the 3rd party components all .Net components or are some of them COM dlls? If you are using COM then those components will need to be registered on the destination computer before they will work.
  10. Are you logging onto both computers with the same username / password - if not then integrated security is likely to fail, it really only works well when there is a central domain so the username / passwords are consistent across all PCs. In a workgroup you may find SQL Standard security is a simpler choice. Have you tried rebooting the SQL server as I've never know SQL to disappear because of a failed data import.
  11. There are several ways to pass information between webpages - Session, querystring etc. http://www.xtremedotnettalk.com/showthread.php?t=78434 covers the main ways.
  12. Although the functions still exist you really should use the newer .Net methods. Look at the classes un System.IO for a starting point and also search MSDN for serialization. If you have a particular problem / question post the relevant code etc and we'll see what we can do. You may find http://www.xtremedotnettalk.com/showthread.php?t=39585 useful as well.
  13. If the string contains a delimited list then you will not be able to simple turn it into a single integer - you will have to split the string down into individual items and parse each in turn. The following will turn a list of numbers into an array of ints Private Function GetNumbers(ByVal s As String) As Integer() Dim nums() As String = s.Split(",") Dim ints(nums.Length - 1) As Integer For i As Integer = 0 To nums.Length - 1 ints(i) = Integer.Parse(nums(i)) Next Return ints End Function Call it like Dim s As String = "3,9,12,35,34,23,67,68,456,457,458,56,76,66,67,90" Dim numbers() As Integer numbers = GetNumbers(s)
  14. try [DllImport("gdi32.dll")] static extern uint GetPixel(IntPtr hdc, int nXPos, int nYPos);
  15. templateMain = templateMain.Replace("","OIN Intranet"); The string functions return a new string rather than modifying the existing string, you just need to assign that to the original string variable.
  16. How is security set up in this environment? Are the two PCs in a domain or just a work group? If they are in a workgroup are you trying to connect with integrated security - if so you will need to make sure that you are using the same username and password on both boxes.
  17. You could just pass the form in as a parameter but that would require knowledge of the calling forms structures (or impose a standard) - if one form required a listbox and another a grid then things could get messy. You could use a standard interface and require one or more functions to be present - but this means forms have to provide all the interfaces methods and if you require one form to have multiple implementations of the interface it can get really confusing. Using a delegate simple means a single form can implement the callback how it sees fit (even have multiple implementations) without imposing too many restrictions. The only drawback is that delegates currently incur a slight performance hit when compared to interfaces / virtual functions but this is being addressed in the next version and the speed is now comparable.
  18. Worked perfectly well here - are you trying to scroll vertically or horizontally? Your code will scroll it vertically down by 300 pixels from it's start position - if the scroll bar is already 300 pixels down then it will not appear to move.
  19. And nothing happened at all or did it just not scroll to the correct position?
  20. What do you mean by didn't work? Just had a quick play with the autoscrollposition property and it certainly scrolled the control around okay. Could you post your code and a brief description of what it should do - it's a lot easier to see problems when the code is visible.
  21. Could you give a bit more detail about what you are trying to do - is it set the scroll to an absolute position or simply allow a particular control to be visible? If the latter then the panel has a ScrollControlIntoView method which does it for you. If you need to set it to a particular position how are you attempting this? Could you post your existing code? Also is there a reason why you are resorting to API calls rather than the native .Net functionality to achieve this?
  22. Had some spare time ;) given the following worker class Public Class WorkerClass Public Delegate Sub FormCallback(ByVal info As String) Public Sub DoSomeWork(ByVal data As String, ByVal CallBack As FormCallback) 'do things here Dim s As String = data.ToUpper 'and when finished CallBack(s) End Sub End Class it firstly defines a delegate - this can be thought of as a type-safe function pointer, it can contain the address (or point to) any function that matches it's signature. In this case the delegate defines a sub routine that expects a single string as an argument. The function that does the work (my example is a fairly loose definition of work ;)) now accepts two parameters - one that is the data to work with and the other is a function that is compatable with the previously declared delegate. This function does whatever it needs to do and at the end it calls the delegate function (actually calls whatever function the delegate points to). To use this from a form we have the following code Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim c As New WorkerClass c.DoSomeWork(TextBox1.Text, AddressOf WorkDone) End Sub Private Sub WorkDone(ByVal result As String) MessageBox.Show(result) End Sub Here we define a WorkDone method that is compatible with the classes' FormCallback delegate (simply displays the string in a messagebox). In the button click we define and instantiate a new instance of the worker class, and then call it's method - passing a string into the first parameter and then the address of our Workdone method as the second. When the application is run the class will call this form's method - if other forms define their own implementation then they can pass those in at runtime and have them called correctly.
  23. When you call a function in the class you probably want to pass a callback function in as a parameter - search MSDN for delegate to get the general idea. Alternatiively if you post a sample function from your class I'm sure we can knock up a sample.
  24. This has been raised several times - once in the past week, try these for starters http://www.xtremedotnettalk.com/showthread.php?t=87289&highlight=decompile http://www.xtremedotnettalk.com/showthread.php?t=82869&highlight=decompile http://www.xtremedotnettalk.com/showthread.php?t=82112&highlight=decompile http://www.xtremedotnettalk.com/showthread.php?t=77883&highlight=decompile http://www.xtremedotnettalk.com/showthread.php?t=78497&highlight=decompile
  25. You could always use a CurrencyManager for this kind of thing. Try this - create a new form and add two text boxes and two labels (you can work out the names from the code below) and then paste the following into the forms code (the declarations section should do it). Private conn As New SqlClient.SqlConnection("Data source=localhost;Initial Catalog=Northwind;Integrated Security=true") Private cm As CurrencyManager Private dt As New DataTable Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load conn.Open() Dim da As New SqlClient.SqlDataAdapter("SELECT * FROM Employees", conn) da.Fill(dt) TextBox1.DataBindings.Add("Text", dt, "FirstName") TextBox2.DataBindings.Add("Text", dt, "LastName") cm = DirectCast(Me.BindingContext(dt), CurrencyManager) End Sub Private Sub btnMoveNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMoveNext.Click If cm.Position = cm.Count - 1 Then MessageBox.Show("You're at end of the records") Else cm.Position += 1 End If End Sub Private Sub btnMovePrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMovePrevious.Click If cm.Position = 0 Then MessageBox.Show("You're at the beginning of the records.") Else cm.Position -= 1 End If End Sub
×
×
  • Create New...