Jump to content
Xtreme .Net Talk

Squirm

Leaders
  • Posts

    186
  • Joined

  • Last visited

Everything posted by Squirm

  1. Windows platform invoke with the [api]QueryPerformanceCounter[/api] and [api]QueryPerformanceFrequency[/api] functions: Declare Function QueryPerformanceCounter Lib "kernel32" (ByRef lpPerformanceCount As Int64) As Int32 Declare Function QueryPerformanceFrequency Lib "kernel32" (ByRef lpFrequency As Int64) As Int32 Dim pcFrequency As Int64 Dim pcStart As Int64 Dim pcCurrent As Int64 Dim pcElapsed As Double 'In class constructor: QueryPerformanceFrequency(pcFrequency) 'When start timing: QueryPerformanceCounter(pcStart) 'To get elapsed time since start: QueryPerformanceCounter(pcCurrent) pcElapsed = Convert.ToDouble(pcCurrent - pcStart) / Convert.ToDouble(pcFrequency) pcElapsed *= 1000000 'Time diff. in microseconds Hope this at least provides a starting point. AFAIK there is no higher resolution timing that these functions.
  2. Its all down to the registry. Let's imagine you wish to register a file type called MyApp Document with the .xyz extension. First create the following key: HKEY_CLASSES_ROOT\MyApp.Document\Shell\Open\Command In this key you place the command-line statement you wish to be executed when a file of type MyApp.Document is opened. The variable %1 denotes the filename. Some example values might be: C:\Program Files\MyDir\MyApp.exe %1 C:\Program Files\MyDir\MyApp.exe "%1" C:\Program Files\MyDir\MyApp.exe OPEN "%1" Next, you need to associate the extension .xyz with MyApp.Document. You do this by creating the following key: HKEY_CLASSES_ROOT\.xyz In this key set the value to MyApp.Document. This completes the file association process. To associate an icon with your file, create the following key: HKEY_CLASSES_ROOT\MyApp.Document\DefaultIcon In this key place the full path and name of the module (EXE or DLL) which contains the icon followed by a comma and then the resource index of the icon you wish to use within the module.
  3. It is rather a cumbersome method you are using there. A much more efficient method would be to remove the character from the original string when adding it to the shuffled string: Public Function Scramble(ByVal textus As String) As String Static rand As New Random() Dim result As String Dim i As Integer Dim pos As Integer For i = 1 To textus.Length pos = rand.Next(0, textus.Length - 1) result += textus.Substring(pos, 1) If (pos) Then textus = textus.Substring(0, pos) + textus.Substring(pos + 1) Else textus = textus.Substring(1) End If Next Return result End Function
  4. Once more, since you don't seem to understand: HourlyEmployee hourEmp = new HourlyEmployee(); Employee emp = hourEmp; //Ok! emp.SomeMethodWhichIsPartOfEmployeeClass(); //Ok! emp.SomeMethodWhichIsPartOfHourlyEmployeeClass(); //Bad! ((HourlyEmployee) emp).SomeMethodWhichIsPartOfHourlyEmployeeClass(); //Ok! I hope you can see the difference here. By casting an HourlyEmployee to type Employee you can only call those methods which were inherited from Employee, you cannot call the 'new' HourlyEmployee methods without first casting back to HourlyEmployee. This is a design paradigm of OOP and is reflected in all languages. Can you show an example of when this isn't the case? To use a different example, imagine the 'thoughts' (for lack of better term) of the compiler when it hits this line: emp.SomeMethodWhichIsPartOfHourlyEmployeeClass(); //Compiler thinks: //hey! emp is an Employee, but there's no such method for Employee! //It doesnt KNOW that this Employee is actually an extended //class with that method, all it knows is that it is dealing with an //Employee and Employees cant do that! If you're still not convinced, please post the code which compiles in C++ but which cannot be reproduced in .Net. :)
  5. The same way you did in VB6 -> [api]PlaySound[/api]. Convert that declare to VB.Net as demonstrated here and you get: Declare Ansi Function PlaySound Lib "winmm" Alias "PlaySoundA" _ (ByVal lpszName As String, ByVal hModule As Integer, ByVal dwFlags As Integer) As Integer
  6. You seem to misunderstand what this forum is for and how we operate here. This is not a cut-and-paste code shop. You come to us with your coding problems and questions and we work with you to find solutions. We do not do work on request. Try http://www.rentacoder.com
  7. [DllImport("odbc32.dll")] extern short SQLSetConnectOption(int hDbc, short iOption, int lValue) I also suggest you check out Derek Stone's tutorial on Platform Invoke. Yes it is for VB.Net but with a little ingenuity and common sense you can use the same principles in C#: http://www.elitevb.com/content/01,0075,01/01.aspx
  8. He means Click here, scroll down and choose a different Style Set. Then click Submit Modifications and try to view the Top 10 Posters again.
  9. If you read MSDN, you'll see that the second parameter for PlaySound is a handle to the module which contains the sound resource, if playing from resource. Since you aren't playing from resource, this should be zero.
  10. You're passing SND_SYNC which means the method would not return until the sound has finished playing. If the sound were being looped it would never finish and so the method would never return. The application would hang indefinitely at this point. Try using SND_ASYNC instead.
  11. Please see your other thread: http://www.visualbasicforum.com/showthread.php?p=479753 In future do not post the same question on both sites. You are either using .Net or you're not, so make up your mind and post the question on the appropriate site.
  12. Compare the number of opening parenthesis to the number of closing parenthesis and you'll see they dont match. Remove the duplicate closing parenthesis.
  13. Re-read wyrd's post. He mentions 2 methods. Look into the usage of For...Next loops.
  14. There is a converter utility, but by all reports it generates awful code. I suggest you recode the entire thing from scratch. Its the only way you'll retain control and understanding over what your code is doing.
  15. The 2002 IDE has an annoying habit of sometimes compiling the program but not actually launching it, while at the same time appearing to launch it. Its happened to me a lot - sometimes 5 or 6 times in a row. You need to stop the application, then run it again. Hopefully this will solve your problem.
  16. Pinball game? (yet to see an attempt at this) Lemmings style game? Turn-based strategy game? Real-time strategy game? Worms style strategy game? (Scorched Earth perhaps) Side-scrolling shooter? Point-and-click adventure? (yet to see an attempt at this) Tycoon style building game? Even within these categories there are sub-categories. Plain 2D or isometric, or even 3D. Multiplayer or single player. And so on...
  17. To register: /nickserv REGISTER <pass> <email> To identify (log in): /nickserv IDENTIFY <pass> For further help: /nickserv HELP Or you can join the #IRCHelp channel. :)
  18. Maybe something like this? Declare Ansi Sub LoadUp Lib "whatever.dll" ( _ <MarshalAs(UnmanagedType.AsAny)> ByRef lpStart As Object, _ <MarshalAs(UnmanagedType.I4)> ByVal iStartLen As Int32, _ <MarshalAs(UnmanagedType.LPStr)> ByVal strRes As String, _ <MarshalAs(UnmanagedType.I4)> ByVal nResLen As Int32) You must be using System.Runtime.InteropServices.
  19. Where did the extra diamond come from? :confused: Also, that solution seems highly illogical. Perhaps you could explain your reasoning.
  20. Why on earth would you need to do this?
  21. You could use the ReadOnly property instead of the Enabled property.
  22. LOWORD = Number & 0xFFFF; HIWORD = Number >> 16; :)
  23. Hint: mutant's avatar is a clue.
  24. Full-time CS degree student just finished (today) my first year. The course is in Java, VB is more of a hobby. I'm still using VB6 and C++ a lot and am more active over at our sister site. :)
  25. With VC++ 5, 6 etc we had MFC (Microsoft Foundation Classes). The IDE provided a form/dialog designer for MFC applications. However, a lot of programmers stay away from MFC, preferring to do everything the hard way (Win32 API). With VC++.Net we still have MFC, but you can also use Managed Extensions.
×
×
  • Create New...