Jump to content
Xtreme .Net Talk

snarfblam

Leaders
  • Posts

    2156
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by snarfblam

  1. Miker_R: About this... As far as C++, if a compiler actually uses your recommendation to inline here is the syntax: inline void myfunction() { //Code goes here } It is a modifier of sorts (or "attribute" as you put it). It tells the compiler that instead of compiling it as a function at all, it should just be inserted everywhere the code calls this functions. So no, it is not used on a per-call basis. But our cries to be inlined are ignored. The compiler knows best.
  2. I was unaware that anyone expected me to save my settings any other way than registry keys. This is news to me. Well... I personally plan on continuing to use the registry until I see some sort of good reason why I shouldn't. Hmm... look at me; only twenty years old and I'm already becoming old fasioned.
  3. I have ported a VB6 program to VB.NET. The program needs to read blocks of bytes from a file. Here is an example of the sort of code I use in many places in the file: FileGet(FileNumber, GameText) GameText is a one dimensional array of bytes. This works fine with option strict off. When I turn option strict on there is, quite understandably, an overload resolution failure. I tried casting GameText to a System.Array and instead of reading the data, the array I got was the unmodified array filled with zeros. I tried casting to an object and got a security error(?). I don't know which overload is being called but it must be FileGet(Integer, System.Array, [integer]) or FileGet(Integer, Object, [integer]). I would think the first which accepts an array. I don't see how, but could the casting to type System.Array cause a problem with the ByRef argument (the array that I am passing)? Am I wrong in expecting the first overload i mentioned to be the one that is called? Can somebody please help me? BTW: I would change it over to the filestream class but I am more familiar with the old vb6 way and more importantly there is a lot of code involved that would have to be changed. It is not out of the question but I would certainly rather not change all that code. [Edit]The security error only happened once. Casting to an object seems to have the same effect as casting to an array.[/Edit]
  4. I don't see how it would make any sense to inline anything but small functions. In a large function the of the overhead of a function call is relatively tiny. Usually negligible. Although it is nice to now what the actual size limit is. And the inline keyword in C++ always struck me as odd. Why include it in the language if it is simply ignored. Suppose it ought to be there just portability for those compilers that might actually use it, but the first tip of the day when you open Visual C++ should be "DON'T BOTHER USING INLINE! IT DOESN'T DO JACK!"
  5. The biggest difference is the syntax. C# is C style syntax and VB.Net is... well... what it is. People who are used to java, php, c++, c, half of everything out there, will prefer C# syntax. The other differences: I don't know them all. I almost always use VB. I know that C# includes unsafe code, which allows you to use pointers. It has strict type checking, like option strict always being on (which most C# users and probably even most VB users think of as a good thing). I can't think of any other differences off the top of my head, but someone else will probably fill you in.
  6. You can create a bitmap object, which has a constructor that accepts the filename, use the SetPixel() method, and resave the bitmap. I'm not sure if this will do exactly what you want.
  7. I know it would compile. What I don't know is when an exception will be thrown: when my assembly is loaded, when the method containing the missing method is invoked, or only if I were to attempt to invoke the missing method.
  8. If I target my application to either version of the .NET framework (so that version 1.0 users can still use my app) and include a call to a function existant only in version 1.1 (Application.EnableVisualStyles() to be specific), but only if the version of the framework running is 1.1, will I still encounter an error because of the reference to a nonexistant function? Here is my code: If Environment.Version.Major = 1 AndAlso Environment.Version.Minor = 1 Then Application.EnableVisualStyles() Application.DoEvents() End If Application.Run(New ZTechForm) 'Begins the program with an instance of our main form
  9. ...32 Views and no replies All I can say is that I'm fine with my current landcruiser/tank. The one you linked to seems to be designed with functionality in mind rather than comfort or luxury, and only seats five. You aren't really gonna buy that model, are you?
  10. Just a note about VB.Net standard: It has no library (DLL) project templates or project settings. You can only use VB.Net standard for libraries if you have an existing library project (or modify the project file manually). Try sharpdevelop... it is a free .NET IDE that comes with more templates for VB/C#/C++ projects than microsoft's standard versions. And its free. Can't go wrong with free.
  11. As was pointed out the your problem was not garbage collection. But I just have some notes about garbage collection that I would like to share. If an object has a .Dispose method then by all means, dispose of it. It will free up any unmanaged resources. As far as garbage collection goes, I don't know if it is the VB compiler, MSIL compiler, or what exactly that does it, but something determines "safe points" where the garbage can be collected without causing you any worry or problems. Although some good practice on your part might help making memory management go more effiecently, you generally don't need to take any precautions when it comes to garbage collection .
  12. Forgive me all you c# users but I do know know how to do this with a filestream off the top of my head, so here it is using the dreaded VB libraries... Dim FileNumber As Integer = FreeFile() FileOpen(FileNumber, ExistingFile, OpenMode.Append) Print(FileNumber, AppendedText) FileClose(FileNumber) ExistingFile would be a string that contains the name of the file you want to append to. AppendedText is... you guessed it, the text to append. Maybe someone more familiar with the FileStream class can show you a "better" way to do it. I've been accessing files the VB way for years and some old habits die hard.
  13. In your origional message: you used "double quotes". If you want "double quotes" then enter the string like Dim s As String = """this""" '= "This" If you want 'single quotes' (which i don't think you do) then enter the string like Dim s As String = "'this'" '= 'This' If you mean something else then I don't follow.
  14. Why are either of you using a function to place quotes in strings? Plausibly Damp is right about the Environment.GetFolderPath function. If you must include quotes in your string, however, do it like this: Dim s As String = """C:\Program Files""" The double double quotes inside the outmost quotes will be parsed by the compiler as single double quotes... almost like an escape sequence. It looks confusing, but try it.
  15. If you hide only the folders in your root drive then the users will still be able to access the files easily enough. Just click start->run and enter c:\windows or c:\program files. Hiding every single file on your computer will make it pretty difficult to use (not to mention might take a while for your computer to do). Your desktops and start menus will be kind of empty. Also, I'm not sure, but I believe that even a limited user account can still set explorer to show hidden files. The fact of the matter is that hiding files is not very much of a security measure at all. Since it is not a per-user setting, they will be hidden from you too. If those with whom you share the computer can't be trusted to access the hard drive you really shouldn't be sharing a computer with them. Why are you trying to hide all the files?
  16. This is the "code" we were referring to Nerseus: And Mookie, to quote you again...
  17. Mike_R... the following code: interface IFace3 : IFace1, IFace2 { } does not inherit IFace1 and implement IFace2. In fact, I'm not even sure if you think it does. There is a hole in your logic somewhere though. Interfaces in both VB and C# support multiple inheritance. In the code above both IFace1 and IFace2 are being inherited, not implemented, in the interface IFace3, and the resulting interface will contain the combined set of functions from both interfaces. This is also allowed in VB. Interface IFace3_BAD Inherits IFace1 Implements IFace2 ' <-- ** No good ** End Interface Interface IFace3_GOOD Inherits IFace1 Inherits IFace2 ' <-- * Kosher * End Interface My best guess as to why the word implements was in the decompiled code instead of inherits is some sort of bug or mistake on the part of the progammer who made the decompiler. If it tells you that one interface implements another you can probably safely assume that it actually inherits it. I would also make the same sort of assumptions about the other abnormalities you found.
  18. I believe that althought setting Me.Font will change the font the controls on the form, the mainmenu and all it's sub menus will always inherit the font specified by the windows user. There is no .NET api that I am aware of that provides this functionality unless you want to set the MainMenu.OwnerDraw property to true and draw the menu yourself.
  19. Is it just me, Nerseus, or have you picked up a habit of repeating me?
  20. If you want to initialize all the elements and you know how many elements you will have before you compile you could do this: Dim Singles as Integer() {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1} If you don't know beforehand, but you want each element to have the same value, make a function to do it for you. 'Edit: I put sub instead of function by accident Public Function MakeMeAnArrayOfSinglesPlease(ArraySize As Integer, InitialValue As Single) As Single() '<--Edit: forgot return type Dim NewArray As Single() = New Single(ArraySize - 1) {} For i As Integer = 0 To ArraySize - 1 NewArray(i) = InitialValue Next i Return NewArray End Sub
  21. Many times I wished to examine raw binary data in files to extract/modify data but usually had no idea where to even start. I think that would be an excellent forum topic but I'm not sure that the idea will be popular enough to actually work well as a forum. It would certainly be worth a shot though.
  22. I believe that that is exactly what the code provided does. Enumerates through all the top level menus in MainMenu1 and sets their enabled property to false.
  23. I noticed it right away when I saw the topic but... i thought it would be rather pointless and somewhat immature to bother pointing it out. And you call yourself a moderator:p.
  24. Well, it seems kind of random... but not uncalled for. So sure, "THANKS MODERATORS"
  25. Im not too familiar with regular expressions but looking at your code i noticed that you declare a new regex with every iteration. Thats a lot of iterations, so of course you will generate a lot of objects. If it is not necessary to create a new one each time then that can save you oodles of memory. I also don't know a ton about the garbage collection, but I'm not sure that it will occur in the middle of a function like that. I haven't the slightest idea as to whether or not this will work but if you call doevents every now and then it might give the app a chance to do garbage collection. With an operation this big you want to call doevents every now and then just as to not hog 100% of the cpu. You could also call gc.collect(). Calls to gc.collect can cause memory to be managed worse later in the app though because you are forcing any objects still in use into later generations, so be careful with that one.
×
×
  • Create New...