Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
TitleX \ COL_WID
Keywordsquick question, quiz
CategoriesTips and Tricks
 
Const COL_WID = 1.25
Const ROW_HGT = 2.5

Dim row As Integer
Dim col As Integer
Dim X As Single
Dim Y As Single

    ' Get the cell's location.
    col = 7
    row = 3
    X = col * COL_WID
    Y = row * ROW_HGT

    ' Verify the row and column.
    Debug.Print col & " = " & X \ COL_WID
    Debug.Print row & " = " & Y \ ROW_HGT
 
This code produces the output:

    7 = 9
    3 = 4

  1. Why don't the calculated row and col values match the original values?
  2. Compare the data type "promotion" performed by Visual Basic in the following two statements:
      X = col * COL_WID
      Debug.Print col & " = " & X \ COL_WID
  3. What are the correct Debug.Print statements?

Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated