![]() |
PEEK and POKE in VBby (Login burger2227)R '\\ API declarations... Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Long, Source As Long, ByVal Length As Long) Private Declare Sub CopyMemoryByte Lib "kernel32" Alias "RtlMoveMemory" (Destination As Byte, Source As Long, ByVal Length As Long) Private Declare Sub CopyMemoryFromByte Lib "kernel32" Alias "RtlMoveMemory" (Destination As Long, Source As Byte, ByVal Length As Long) 'These are then used in standard functions thus: Public Function Peek(Address As Long) As Long Call CopyMemory(Peek, ByVal Address, Len(Address)) End Function Public Function PeekByte(Address As Long) As Byte Call CopyMemoryByte(PeekByte, ByVal Address, Len(PeekByte)) End Function Public Function Poke(Address As Long, Value As Long) CopyMemory ByVal Address, Value, LenB(Value) End Function Public Function PokeByte(Address As Long, Value As Byte) CopyMemoryFromByte ByVal Address, Value, LenB(Value) End Function 'Example of use.... Dim lTest As Long lTest = 100 Debug.Print lTest Poke VarPtr(lTest), 300 Debug.Print lTest 'Ted
|
Resourcesby Anonymous (no login)If I have lots of resources and I dont want to put them all in the main .exe file what can I do? |
Resource filesby Solitaire (Login Solitaire1)S Data is saved in a Resource file which becomes part of your project. If you choose Project resource file, it will place the file inside your project folder, making it portable. If you select Local resource, it will not become part of the project. But if you move your project folder elsewhere, it will not be able to find the selected file, so you need to use extra code to locate the file on the current computer. Sorry I can't give you more details, but I only have limited experience working with Project resource image files. Not sure how or even if you can change from Project to Local after the original choice was made. I hope I gave you enough information so you can try to work it out for yourself. |
How?by Anonymous (no login)I use VB2008 where can I change that? |
* Sorry we don't answer anonymous people. Get a name!by (Login burger2227)R |
*Yes we do, that's why we don't require registration.by (Login PhyloGenesis)R * |
* Qbasic code CAN be used in VB! Ask here.......by (Login burger2227)R
|
SWF Componentby JPCS5917 (no login)Hi I saw a topic in a forum about hacking flash games using VB6.I have VB2008 but I need a SWF Component that I cant find in 2008.Im using windows vista so my VB6 install program doesnt work.What can I do now? |
What exactly are you trying to do?by (Login burger2227)R Did you try searching Google? I found a SWF to bitmap program for .NET here: http://swf-to-image.bytescout.qarchive.org/ I searched "VB swf components" Ted PS: If you EVER want to use VB6 again downgrade to XP. VISTA sucks!
|
Have you tried...by (Login MystikShadows)VB-Forum To right click on the setup icon and making sure you select "run as administrator" ? |
* I think he should have bookmarked the Forum. :Pby (Login burger2227)R |
* that sounds like a good idea yes. ;).by (Login MystikShadows)VB-Forum |
* Solitaire and I should be able to answer most questions.by (Login burger2227)R
|
* Mystik is on a moving sabbatical. Hope they have Internet there!by (Login burger2227)R
|
Why?by Iain (Login Iain_Mcphee)R It seems that if you follow M$'s programming conventions for VB.NET, you end up with code that I can't read and uses far too much memory. |
Because M$ thinks they can just redo anything they want.by (Login burger2227)R The hell with backward compatability too! Full speed ahead! "M$ needs more money for Bill's pension." Ted
|
Merry Christmas Myst and good luck with moving...by (Login The-Universe)Admin For those who may have wonder why MystikShadows has not been around much this month, he and his family are in the middle of a move. From what I've seen of the weather near where he and his family live, that is no easy task this time of year. Best wishes Myst to you and yours and I hope you will be back with us soon for the New Year. Pete |
Console Calculator with title instructionsby Solitaire (Login Solitaire1)S I just learned about the Console command that changes the title of the window in VB 2005 or VB 2008. I wrote a simple calculator program as a Console application and added the instructions in the title, rather than repeat it on the output screen. I also added more console features that lengthen the screen and give the user option to scroll when reaching the bottom or clearing the screen. Program is designed to permit only valid inputs for the operators. Incorrect number inputs will return 0. Other features were added and improved as I edited the code later this evening. Start a new Console application and copy/paste this code. It should automatically indent each line properly inside the IDE, but you will need to add more spaces in the title string (in place of the underlines) to separate the instructions for Space and Esc: Module Module1 Sub Main() Dim oper As String, first, num As Double, over As Boolean Dim start As Boolean = False Dim result As Double = 0 Dim ent As String = "" Dim sresult As String = "" Dim repeat As Integer = 0 Dim lresult As Long = 0 Dim row As Integer = 0 Console.WindowHeight = 38 Console.Title = "Console Calculator ---- Operators + - * / \ ^ Mod ___ Space clears; ___ Back restarts; ___ Esc exits" Do repeat += 1 over = False If result = 0 And start = False Then Console.Write("Enter the first number: ") ent = Console.ReadLine() Double.TryParse(ent, result) Console.WriteLine() Else Console.WriteLine("The starting number is " & result) Console.WriteLine() End If Console.Write("Type operator, space, Backspace, or Esc: ") Do oper = Console.ReadKey(True).KeyChar oper = oper.ToLower() Loop While ("+-*/\^m " & Chr(27) & Chr(8)).IndexOf(oper, 0) = -1 If oper = "m" Then Console.Write("Mod") Else Console.Write(oper) End If Console.WriteLine(vbCrLf) If "+-*/\^m".IndexOf(oper, 0) > -1 Then Console.Write("Enter the second number: ") ent = Console.ReadLine() End If Double.TryParse(ent, num) first = result Select Case oper Case "+" result += num Case "-" result -= num Case "*" result *= num Case "/" If num = 0 Then num = 1 result /= num Case "\" lresult = Convert.ToInt64(result) lresult \= Convert.ToInt64(num) result = lresult Case "^" result ^= num If result > 1.79769313486231E+308 Or result < -1.79769313486231E+308 Then result = first sresult = ("Result is beyond upper or lower limit") over = True End If Case "m" result = result Mod num oper = "Mod" Case " " result = 0 Console.Clear() start = False repeat = 0 Case Chr(8) row = Console.CursorTop Console.CursorTop = row - 4 Console.CursorLeft = 0 Console.Write(StrDup(160, " ")) Console.CursorTop = row - 4 result = 0 start = False Case Chr(27) Exit Do Case Else oper = " " Console.Clear() End Select If over = False Then sresult = result.ToString If oper <> " " And oper <> Chr(8) Then Console.WriteLine() Console.WriteLine(vbTab & first & " " & oper & " " & num & " = " & sresult) Console.WriteLine() Console.Write(StrDup(80, "=")) End If If oper <> " " And oper <> Chr(8) Then start = True If repeat Mod 4 = 0 And Console.CursorTop >= 34 Then Console.WriteLine("Enter to clear screen, Tab to scroll to top, any other key to continue down...") ent = Console.ReadKey(True).KeyChar If ent = Chr(13) Then Console.Clear() repeat = 0 ElseIf ent = Chr(9) Then Console.CursorTop = Console.CursorTop - 1 Console.WriteLine(StrDup(80, " ")) Console.CursorTop = Console.CursorTop - 2 Console.WindowTop = repeat * 9 Else row = Console.CursorTop Console.CursorTop = row - 1 Console.CursorLeft = 0 Console.Write(StrDup(80, " ")) Console.CursorTop = row - 1 End If End If Loop Until oper = Chr(27) Console.WriteLine(vbCrLf) Console.WriteLine("Press any key to Exit Console Calculator") Console.ReadKey(True) End Sub End Module
|
* Pete, this Forum says "Login" and I cannot edit stuff.by (Login burger2227)R |
* Thanks, it should work now.by Pete (Login The-Universe)Admin |
Counting characters in a stringby Solitaire (Login Solitaire1)S This seems to be a simple problem at first but turns out to be more challenging than expected. Each character in the string is to be output in order of appearance, without duplication, with the number of repeats listed next to it. For example, if the string is "accbedbc" the output should be: a -- 1 c -- 3 b -- 2 e -- 1 d -- 1 Furthermore, it should be done using nested For Each loops, and will probably need to use Char() arrays for comparison. Any ideas? I posted a similar QB problem in the main forum: http://www.network54.com/Forum/13959/message/1222886914/Count+characters+in+string |
How about a Keypress event and an Array?by (Login burger2227)R You can toss the keypress counts directly into the array as the user types it. In QB I would use one INKEY$ loop and filter out invalid characters like spaces and "." for example. Ted |
Here is an Array routine using MID$, ASC and two FOR loopsby (Login burger2227)R DEFINT A-Z DIM Chrs(65 TO 90) FOR i = 1 TO L SYSTEM You could also just print the array in alphabetical order when an index > 0 after it is done looping. Ted
|
Thank you, Clippy, but your code belongs in the main forum, not here.by Solitaire (Login Solitaire1)S It works nicely in QB, but this is for VB.NET. I did specify VB.NET code using >>For Each<< loops and >>Char<< arrays (not available in QB). In addition, I didn't mention it, but legacy code (such as INSTR, MID, etc.) are to be avoided. I'm sure it can be worked out with some effort. FYI: The Substring() method replaces MID. The IndexOf() method replaces INSTR. Both methods are zero-based. The syntax differs from the old legacy functions. Examples: initial = myname.Substring(0, 1).ToUpper() returnvar = mainstring.IndexOf(instring, startpos) The For Each loop construct works with arrays and collections. This is always zero-based. However, For Each always includes the complete array range from 0 to the upperbound value, so individual indexes or ranges cannot be singled out. The Chars() property returns a single character in a string and is zero-based. It takes one number argument -- the location in a string, starting with 0 for the first position. A string can be assigned to a Char array using the stringname.ToCharArray method. Example of extracting letters from an alphanumeric string: Dim newstr As String = "" Dim alfanum As String = TextBox1.Text Dim n As Integer = alfanum.Length Dim carry(n - 1) As Char carry = alfanum.ToCharArray For Each ch As Char in carry If Char.IsLetter(ch) Then newstr &= ch Next TextBox2.Text = newstr |
I knew that! I figured INSTR would create problems too.by (Login burger2227)R IF that is supposed to be the latest in VB.NET programming technology THEN count me out! M$ always has to mess with simplicity and that accounts for all of their Bloated software ......................... plus the excess money we must pay. Not only do they change stuff, but they don't even care about backward compatability anymore! Don't even expect me to play with their new OOPS system of programming, please. I use VB6, but M$ is gonna kill that soon too. Ted
|
Easyby qbguy (no login)SHELL "qbasic /run count.bas" |
Or in Vistaby qbguy (no login)Shell "c:/qb64/compile.exe count.bas" Shell "c:/qb64/count.exe" |
*How true QBguy.............by (Login burger2227)R |