Arrangement of elements in the multi-dimensional array in memory in VB6

Source: Internet
Author: User
1 private declare sub rtlmovememory lib "Kernel32" (destination as any, source as any, byval length as long) 2 3 4 'Code by lichmama from cnblogs.com 5 private sub form_load () 6 dim A (2) as byte 7 dim B (2, 2) As byte 8 dim C (2, 2, 2) As byte 9 10 debug. print "one-dimensional array:" 11 debug. print varptr (A (0), varptr (A (1), varptr (A (2) 12' array element arrangement in memory: 13 'a [0] | A [1] | A [2] 14 15 debug. print "two-dimensional array:" 16 debug. print varp TR (B (0, 0), varptr (B (1, 0), varptr (B (2, 0) 17 debug. print varptr (B (0, 1), varptr (B (1, 1), varptr (B (2, 1) 18 debug. print varptr (B (0, 2), varptr (B (1, 2), varptr (B (2, 2) 19 'array element arrangement in memory: 20 'B [] | B [] | B [] --> B [] | B [] | B [] | B [] --> B [] | B [1, 2] | B [2, 2] 21 22 debug. print "3D array:" 23 debug. print varptr (C (0, 0, 0), varptr (C (1, 0, 0), varptr (C (2, 0, 0) 24 debug. print varptr (C (0, 1, 0), varptr (C (1, 1, 0), varptr (C (2, 1, 0) 25 debug. print varptr (C (0, 2, 0), varptr (C (1, 2, 0), varptr (C (2, 2, 0) 26 debug. print varptr (C (0, 0, 1), varptr (C (1, 0, 1), varptr (C (2, 0, 1) 27 debug. print varptr (C (0, 1, 1), varptr (C (1, 1, 1), varptr (C (2, 1, 1) 28 debug. print varptr (C (0, 2, 1), varptr (C (1, 2, 1), varptr (C (2, 2, 1) 29 debug. print varptr (C (0, 0, 2), varptr (C (1, 0, 2), varptr (C (2, 0, 2) 30 Debug. print varptr (C (0, 1, 2), varptr (C (1, 1, 2), varptr (C (2, 1, 2) 31 debug. print varptr (C (0, 2, 2), varptr (C (1, 2, 2), varptr (C (2, 2, 2 )) 32' array element arrangement in memory: 33'c [, 0] | C [, 0] | C [, 0] --> C, 0] | C [, 0] | C [, 0] --> C [, 0] | C [, 0] | C, 0] 34' --> C [, 1] | C [, 1] | C [, 1] --> C [, 1] | C, 1] | C [, 1] --> C [, 1] | C [, 1] | C [, 1] 35' --> C, 2] | C [, 2] | C [, 2] --> C [, 2] | C [, 2] | C, 2] --> C [, 2] | C [, 2] | C [, 2] 36 37 'We are used to logically assigning values to arrays, it is literally B () = "lhmimaca! "38 B (0, 0) = & h6c: B (0, 1) = & H68: B (0, 2) = & h6d39 B (1, 0) = & h69: B (1, 1) = & h6d: B (1, 2) = & h6140 B (2, 0) = & h63: B (2, 1) = & H61: B (2, 2) = & h2141 42 dim text as string43 text = string (9, "") 44 call rtlmovememory (byval strptr (text ), byval varptr (B (0, 0), 9) 45 debug. print "but the result is as follows:"; 46 debug. print strconv (text, vbunicode) 47 end sub

 

View results (memory address printing ):

One-dimensional array: 2031464 2031465 2031466 2D array: 2048432 2048433 2048434 2048435 2048436 2048437 2048438 3D array: 2059256 2059257 2059258 2059259 2059260 2059261 2059262 2059263 2059264 2059265 2059266 2059267 2059268 2059269 2059270 2059271 2059272 2059273 2059274 2059275 2059276 2059277 2059278 2059279 2059280 2059281 2059282 but the result is as follows: lichmama!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.