Register | Login | |||||
Main
| Memberlist
| Active users
| Calendar
| Chat
| Online users Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album |
| |
0 users currently in Programming. |
User | Post | ||||||||||||||||||||||||||||||||||||
Guy Perfect Posts: 442/451 |
Pointer support has always been limited in Microsoft variants of BASIC, but they really clamped down on it when they introduced Visual Basic.
Back in the days of QBASIC, there were the PEEK function and POKE statement, which could retrieve a byte from memory and write a byte to memory, respectively. Those procedures have since gone the way of Bill Clinton's credibility. The only thing in VB nowadays, leastways with VB6 (VB.NET isnt' my specialty) are very specific "obtain a pointer value only" functions and no ability to write data to memory. The following things exist in VB6: VarPtr Function - Retrieves the address of a variable. Was only available as a DLL import in VB4, but was later added to the IDE with VB5. Example: "X = VarPtr(Y)" AddressOf Operator - Added in VB5 for support with various API calls. It's essentially a function for a procedure name that returns the function pointer of the given procedure. Provided for use with callbacks. Example: "ErrCode = apiUseCallback(AddressOf SomeKindaFunction)" | ||||||||||||||||||||||||||||||||||||
||bass Posts: 586/594 |
Originally posted by Kyoufu KawaPossibly a third? Therein lies the problem. These 'pointers' from the examples look more like specialized pointer-like objects that simply capture the general-esque functionality of true pointers for specific cases. I still fail to see actual pointer support in the language specification itself. (Actual support being something other than what amounts to what appear to be little more than wrapper objects.) | ||||||||||||||||||||||||||||||||||||
Kyoufu Kawa Posts: 1341/1353 |
To finally lay the "no pointers in VB" crap to rest, here's an excerpt from Win32 API Programming with Visual Basic I found in my copy of MSDN. I've marked the important part, StrPtr. There's also VarPtr and possibly a third. Translating Between Byte Arrays and BSTRs To copy a BSTR: Dim s As String
to a byte array, we can proceed in a couple of different ways. For a strictly VB solution, we have: s = "help"
Another approach is: s = "help"
Note that (in both cases) we get: 104 0 101 0 108 0 112 0
showing that the bytes are reversed in each Unicode integer. BriGuy92 |
Posts: 43/43 Wow. The end of the class has come and we finally do something worth mention. Our final project (That of me and Ogama Dobe, that is) was to create a "High Card" game in VB. The game pretty much needed to randomly select one of 52 cards from an array, display it in an image box, and then select another and display it in an image box. The program then had to test to see which one was higher, and determine the winner of the "Hand." It was a pretty complex program, really challenging. (spelling?) I might edit this post with the .exe file as an attachment, if anyone wants to download it. | Kyoufu Kawa |
Posts: 1339/1353 Originally posted by ||bassI think I saw some pointer dabbling in one of the books I have. Was something about string formats and lengths and it involved pointers to a large degree. I might just quote it. ||bass |
Posts: 581/594 Two comments:
| One, to address the idea that VB is somehow totally incompatible with any kind of cross platform programming: That is MonoDevelop, with the option to create/open a VB.NET (not classic VB) project on my home PC running Ubuntu Linux 6.10. Second, a simpler comment. No pointers = utter fail. VB does suck, just not because of the supposed lack of cross platform-ness. MaxKnight |
Posts: 3/7 Thank you asakuS! As for the picturebox, assuming I ever get the right graphics for building the world there, I should be able to put code in to scroll the screen by removing rows and columns of squares from the edges and adding them back again on the opposing side when clicking, right? I'm not nearly that far yet, as I've no clue how to actually go about creating this without using far too many really small pictureboxes in a square pattern.
| Well anyways, should I ever need anything more, I'll be sure to ask, as I know I'll not be able to completely finish this without asking more questions! Sukasa |
Posts: 2028/2068 1) test1.text = "First line" + vbCrLf + "second Line"
| 2) to handle the mouseclicks, set the pictureboexe's scalemode property to 3 - pixels, and then in it's click() event, handle all the clicks there. MaxKnight |
Posts: 2/7 I know this thread is for ranting on Visual Basic, but I figure if you're ranting on it, you must know something about programming with it.
| If this should be posted in a separate thread, please tell me, and I'll do so. I have a few questions. I'm making a program in VB that is to simulate the NES game Dragon Warrior. I have several forms created for the actual game, but need some help with some of the controls. http://img180.imageshack.us/my.php?image=mainformnr2.png This link is to a picture of the main form. All actual gameplay is done here. My questions are as follows: 1) Does anybody know how to force a newline/carriage return in a multiline textbox? Almost everything that is text related will go in there, but for now it all runs together. I have several different subroutines that append text to this textbox, but have no clue how to make it newline so that it doesn't run all together. 2) Believe it or not, there is a picturebox in the center of the image. I want to design it close to how the game worked, with a top-down screen where you can move the hero around, scrolling the screen in whatever direction he's going. I'm planning a point-and-click interface, where you click on the tile you want him to move to, and he moves automatically to that spot. If a battle commences before then, the battle subroutine (yet to be written) takes over, and the move is canceled at the spot of the battle. I may be able to get all of the graphics I need to fill the space, I just don't know how to make it all work. I realize this is a really big undertaking, but it's something I really wanted to do, since about 2003. Sukasa |
Posts: 2025/2068 Interestingly enough, I ran this program on my win98SE 350 MHz computer and it ran like a charm
| A 650 MHz WinXP library computer at school ran it like crap, so I'm thinking that it's just something on that computer that's slowing down my program. I'll look into OpenGL though, for graphics processing. right now I'm using Private DirectX As DirectX8 'The master DirectX object.
To get my input, and just doing a lot of blits for the UI and such: DIBDc = Canvas.hdc 'assign Canvas.hdc to a variable, seems to speed this up
Guy Perfect |
Posts: 441/451 OpenGL is just a graphics pipeline. Input has to come from somewhere else. One good option is to use the GetKeyboardState() function from your main animation loop to get the pressed-ness of each key without relying on VB's Form events.
| You can use DIB Sections with OpenGL if you configure your rendering context to do so. Using that, you can do whatever fancy hardware-accellerated stuff you need, do any manual processing, then BitBlt() it to the destination DC (like the Form's) when your'e done. OpenGL sports a handy viewport mode called glOrtho() that can map polygons to exact pixels on the screen. That's typically the best choice for foreground UI's. Sukasa |
Posts: 2023/2068 Hm, I'll have to look into that. The single biggest slowdown issue in this game is redrawing the non changing UI elements and the battlefield, with I could do with minimal CPU usage is there was a way to create the picture on hardware in somewhat the way the Super Nintendo uses Layers. I'm not going to assume that's possible, though
| And thanks... So, does OpenGL support VB6 and Taking input from the keyboard? Guy Perfect |
Posts: 440/451 OpenGL is indeed faster for the fact that it's not object-oriented and runs for the most part on the video hardware; just simple commands being passed from your program. And while it doesn't apply to VB so much, the fact that DirectX requires use of classes means it can't be used from C, which is arguably the best language to use for compatibility and speed. | Sukasa |
Posts: 2022/2068 Is it faster than DirectX?
| I'm using DirectInput now to get input from the keyboard ,instead of Form_KeyDown and Form_KeyUp. Direct3D made it look like crap, so I'm still using Bitblt, as DirectX8 doesn't seem to have DirectDraw from what I could see :/ And speeding up the program a bit by changing little things, but I really need to figure out a better way to do graphics, those are definitely the slow spot in Battletankz. Guy Perfect |
Posts: 438/451 OpenGL is much easier to use from VB than DirectX. | Sukasa |
Posts: 2020/2068 Using a DIB section, then after everything is done, blitting from the DIB canvas to a picturebox.
| EDIT: Went through, and still can't figure out any possible cause of the slowdown other than that paint routine :/ I'm just going to look at using DirectX 8 for this and see about perhaps using Direct3D or DirectDraw, and switching to DirectInput and DirectMusic for the other parts of the program Guy Perfect |
Posts: 437/451 If you're using a Form or PictureBox as the source of the DC, it'll be slow. Use the GDI to create an in-memory DC and work with that. | Sukasa |
Posts: 2019/2068 ... That's what I've been doing, too... but the routine is insanely slow How big are your blits? I'm running a 640 by 480 canvas, 24-bit colour depth, and I'm doing transparent blits like this:
| BitBlt Canvas.hdc, 0, 0, 640, 480, UI1m.hdc, 0, 0, vbMergePaint
Since I'm getting a fair bit of slowdown, I'm looking through some of my other routines, as I think that a couple other parts of this form are causing a good part of the problem... I know at least one thing that's likely a problem right now Kyoufu Kawa |
Posts: 1336/1353 The regular: set up a backbuffer and BitBlt/StretchBlt other dibs onto it. Lightning fast, but few special effects aside from stretches. | Sukasa |
Posts: 2017/2068 Originally posted by Kyoufu KawaOriginally posted by asakuSOBJECTION! Then what the hell am I doing to make this program so slow? And for arrays of constants, you can make a workaround for this somewhat like this: Dim ConstArray(2) As Long
I've done that a few times. Twips have something to do with printers and the screen or something, Drag. So, Kawa, what did you do to get your fighting game going so fast? I'm going to assume you used a loop, right? I mentioned the Message pump because as I understand C++, that's how *any* windows program gets it's messages, and that VB6 compiles the program with a poor setup for that pump |; This is a long thread. Click here to view it. | |