Solved

Dim Statement

Posted on 2011-02-27
8
285 Views
Last Modified: 2014-06-27
I need a procedure to store the name of an item in inventory and its height and weight.  The height may have a decimal place ; the weight will be whole numbers only.  Write appropriate Dim statements to declare the necessary procedure-level variables.
0
Comment
Question by:RM0517
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
8 Comments
 
LVL 21

Accepted Solution

by:
oleggold earned 168 total points
ID: 34992857
syntax of dim statement is
dim varname integer;
or
dim varname ;
We can write exact statement for You as it's against the rules
0
 
LVL 85

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 166 total points
ID: 34992942
Here are the data types in VB.Net:
http://msdn.microsoft.com/en-us/library/47zceaw7(VS.71).aspx

The keywords in your problem statement are:
The name of an inventory item.
Height may have a decimal place.
Weight will be whole numbers.

Which data types best fit these needs?
0
 
LVL 8

Assisted Solution

by:JT92677
JT92677 earned 166 total points
ID: 34994480
You are describing a "record" -- a type of variable that contains your date

Private Type InventoryType
    ID As Integer
    Weight as real
    Height as real
    Description as As String * 50
End Type

Dim InventoryItem As Inventory Type


you would then access the parts of the record e.g.
 
  InventoryItem.ID = 4324
  InventoryItem.Description = "This is a nail"
  InventoryItem.Weight

etc.

or using the With / end With block

   with InventoryItem
      id = 2342
      description = "this is a nail"
      weight = 3.4
   end with

Bottom line -- you are describing a "RECORD" type and need to keep the various attributes (description, weight, height, etc.) in a single record structure or record type.

Then you can create instances of the record using the DIM statement.

Hope this points you in the right direction

jeff
0
 
LVL 8

Expert Comment

by:JT92677
ID: 35003539
Any guess as to whether RM0517  will assign points to an answer?

The issue is about record types, but I don't see a solution to the "write a procedure" question, hopefully I haven't broken a rule by posting info on record types and how to access the fields within the record.

Ask a question, get an answer, didn't know about the homework rules, sorry. But don't think my suggestoins are a "complete solution" ??

Jeff
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question