calculation (1 Viewer)

AljayB

Registered User.
Local time
Today, 08:01
Joined
Dec 2, 2015
Messages
19
Hello there,

I am trying to make a calculation form.
in there I have 7 text boxes in which the user can type down a number which then gets calculated.
this now looks like this:

Dim a As Double
Dim b As Double
Dim c As Double
Dim d As Double
Dim e As Double
Dim f As Double
Dim g As Double
Dim h As Double
Dim resoult As Double

a = Me.txtmasse1
b = Me.txtmasse2
c = Me.txtmasse3
d = Me.txtmasse4
e = Me.txtmasse5
f = Me.txtmasse6
g = Me.txtschnitt
h = Me.txtSekunden

resoult = (((a + b + c + d + f + e) / f) * 600) / h

Me.txtMFRAuswertung = resoult

Now this works when all fields contain a value, but what if one or more fields were left empty, how do I make it so the calculation would still go on, by skipping the empty fields from b-e?

I-m new to VBA so don't have much experience yet...

many thanks in advance!
 

namliam

The Mailman - AWF VIP
Local time
Today, 16:01
Joined
Aug 11, 2003
Messages
11,696
Try using the NZ function or is it NVL? I think NZ...
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:01
Joined
May 7, 2009
Messages
19,175
a=nz(me.txtmasse1, 0)
b=nz(me.txtmasse2, 0)
... and so on
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:01
Joined
May 7, 2009
Messages
19,175
a=nz(me.txtmasse1, 0)
b=nz(me.txtmasse2, 0)
... and so on

On Error Goto Err_Handler
resoult = (((a + b + c + d + f + e) / f) * 600) / h
Me.txtMFRAuswertung = resoult
Exit Sub

Err_Handler:
resoult= 0
Resume Next
Resume
 

Users who are viewing this thread

Top Bottom