VB depth diving one meter depth (Getting Started with VB)

xiaoxiao2021-03-06  50

Forehead

I also agree with the online popular point of view, VB is just a toy. It is true that as a VB ordinary user can't play more Dongdong. However, these months I completely regardless of the Normal Application of VB, but a piece of COM's ocean, with a small sail of Pan Aimin, "COM principle and application" and a bag of dried food "Advance Visual Basic". Actually transferred for a few months in the Icy Technology Ocean. Finally found a VB shocking fan. Then I have this long article.

If it is not accidental, in the fifth pen, VB is the word "good". But what I said is not to refer to this. Please follow me to see the cloud, see what VB is. If you all see the following facts, I believe that you will not say VB is a toy.

At first, Bill's spirit was running on the water.

Bill said there must be DOS, so there is DOS.

......

On the eighth day, Bill said that there is VB, so I created VB.

"3S New Approach Chapter"

Deep dive

You need a good set of diving clothes (VB6.0 Enterprise Edition, you won't say you, in fact, I only have a D version, huh, huh), a submemberroscope (OleView with VC6.0), of course you have to have Good swimming technology (solid COM technology and C / C creature, but I am not very good), but the most important thing is that you can endure this painful experience. If you are PLMM, you can contact me directly, I will protect you safe, huh, huh.

Everybody, OK? Lets Go

first day

Dive depth (one meter, water temperature 0 ° C), time Beijing time zero.

"Hello everyone! I am BlueDog, the captain of this adventure, in fact, I am not a love, huh, ha, although many MMs make me dream people."

"You are uncomfortable, why everyone is vomiting, he knows, this is normal, it is a halo."

"呯!"

. . . . . . .

Ok, please say less. Take out your JJ (exercise, I refer to your machine, computer, computer, don't understand!)

Open a VB project to build a standard EXE. Next, we need to use the VB pointer, when I don't finish it, a mosquito said: "There is no pointer in the boss, VB."

"", The world is quiet!

"I don't like someone to interrupt my speech, hehe!"

By the way, before the water, I have not sent you a very important equipment oxygen bottle (3S Ole Typelib), which is an essential tool for home travel and killing.

"Where is it to buy?"

http://www.xtcz.net/bbs/dispbbs.asp?boardid=8&id=1096

After you download, you need to decompress, you will get a 3SoleLib.tlb file, this file is imported in the United States, China's original production. So I use this file I don't guarantee that there is no lawsuit to be entangled. At least if you are used for commercial software, you have to ask me to eat local big gear, as your usage.

Then use the most classic DOS command

Copy C: /3soleLib.tlb C: / Windows / System32

Ok, you then choose the project in your newly built project -> quote, quote this file, will not be used, go to death.

Then there is a very wonderful thing? ? ? No, halo, boss, you press F2 to see, is there a more Oleelib's stuff

do not know? Go to death, suffer from my refreshing box.

What is the use? Ok, let me tell you what is used.

In the past, do you write an API to use the stable, you can't use it now, you can use this API directly, at least for most of the API related to COM. (After specific reasons, explain)

If you really don't understand, don't you tall, who told you to be Guo Jing? We need a very important stuff, you can find MoveMemory in the object blogger, or you can find the following related definitions.

Sub MoveMemory (pdest as any, psource as any, bytelen as long)

This is the Dongdong we have to find today.

Let's add a button on an Form. Then entry in the CODE interface

Private submmand1_click ()

DIM I as long

DIM J AS Long

i = 3

J = 4

MoveMemory Byval Varptr (i), ByVal Varptr (j), 4

Debug.print i, j

End Sub

Run, look, what happened. The value of i has also become 4, which is true. God. What happened. Let's take a look at what happened.

First we see Varptr, the teacher tells us that there is a question asking MSDN, but MSDN did not tell us. Go to Google check, there are few things, it turns out the address of the variable. Located in the vb's object blogger, open the display implied member, then find it, VB will display

Function Varptr (PTR AS Any) As Long

VBA._HIDDENModule member

Bill hides this stuff here, there is Objptr, Strptr, and what is the use of Objptr, and strptr is a string address. These two Dongdong will talk tomorrow.

So, what is another MoveMemory? Let's take a look at MSDN's original text

The MoveMemory Function Moves A Block of Memory from One Location To Another.

Void MoveMemory

Pvoid ​​Destination, // Address of Move Destination

Const void * Source, // address of block to move

DWord Length // Size, in Bytes, Of Block To Move

);

For Sanskrit bad classmates, I will translate it ("The role of MoveMemory is to move a pile of money from a pocket to another, it is too good, then if you write

MoveMoney (Mybag, Bossbag, 1000000000000)

Big brother, see the point is Memory is not Money!

Then

You can only move the data of a memory to another.

This is the case.

In fact, I have made this stuff very early, and the VB door can also practice the sunflower book like the C-do not use it as a Centers. It's really a lot of luck. However, he redefined CopyMemory, in fact, there is no Dongdong in the Windows API.

Ok, jokes are less talking, look at the line of code above, what is the line of code, byval Varptr (j), 4

Is it pointing from J to 4 bytes (long "to i.

Excellent, but you still have a place, I don't pay attention, why do I want to use Byval without byref?

Do not believe, you use

MoveMemory Varptr (i), Varptr (j), this line of code instead of the above line, then run,

The mountain is still the mountain, I is still equal to 3, so we will also come to carefully study the definition of MoveMemory in the oxygen cylinder.

Sub MoveMemory (pdest as any, psource as any, bytelen as long)

It is not seen in VB.

Specify the AS ANY to disable type checks, allowing any data type to be passed to the process

Then if we use byval, it is the address value of J.

And by Byref is the address value of the temporary variable of the address value of J.) so.

understand?

If you don't understand, it is the so-called qualification, huh, huh, don't blame you.

This classmate said again, if this is the case, I don't use it directly.

MoveMemory I, J, 4

Just, why is it so troublesome? Smart, you look at the ability of people.

But I just told everyone how Varptr is used.

Another classmate said, in fact, there is a simpler

I = j

pig.

At this time, the depth meter has shown that it has reached one meter, a classmate exclaimed, "unknown biological attack." . . .

转载请注明原文地址:https://www.9cbs.com/read-87852.html

New Post(0)