Excel 2000 VBA Calc problem

D

Doobage20

Hi all,

I hope I am in the right spot. If not please direct me there.

I am using XP SP2 and Office 2000 Premium SP1. I am trying to find out how
find the answer to a problem. I am in Microsoft Visual Basic trying to take
the value of length and multiply it to get sq feet. The problem I have is
the examples all are referencing a cell from one of the sheets. I am not
using the sheet what so ever. I am hoping to use only the form. So my
equation should look something like this.

sqft = length * width

Am I missing something or going about this the wrong way?

Mark
 
L

Luke Alcatel

Instead of "Microsoft Visual Basic" I assume you mean "Visual Basic for
Applications" aka VBA which I assume you entered from an Excel workbook.
You are correct that you can write general purpose Visual Basic code that
does not reference the worksheet however such use would be unusual. In this
case most people would use Visual Basic, Java, Perl, or another development
language with a graphical API. The obvious reason that examples reference
data in worksheet cells is that VBA applications are typically built around
the interaction of a document and application-specific algorithms.

LA
 
M

macropod

Hi Doobage20,

Here's some simple code that doesn't reference the worksheet:
Sub Area()
Dim Length As Double
Dim Width As Double
Length = InputBox("Please input the length")
Width = InputBox("Please input the width")
MsgBox "The area of a rectangle with a:" & vbCrLf _
& "Length of: " & vbTab & Length & vbCrLf _
& "and a Width of: " & vbTab & Width & vbCrLf _
& "is: " & vbTab & vbTab & Length * Width
End Sub

BTW, by 'Office 2000 Premium SP1' I assume you mean 'Office 2000 Premium SR1' (there was no SP1). There is, however, an Office 2000
Premium SP2 and an Office 2000 Premium SP3, to which you should upgrade.
 
D

Doobage20

Thanks for the reply. What I was looking for was the following:

Private Sub CommandButton1_Click()

Dim cLjsqft As Double
Dim cLjtotal As Double

cLjsqft = Ljlength.Text * Ljwidth.Text
Ljsqft = cLjsqft

cLjtotal = Ljqty * Ljsqft
Ljtotal = cLjtotal

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top