PC Review


Reply
Thread Tools Rate Thread

How to disallow a zero value in an array

 
 
dan dungan
Guest
Posts: n/a
 
      1st Mar 2010
Hi,

Using Excel 2000 and Windows XP professional, I'm using the following
code to create a variable to use in another sub.

In a quoting application I'm designing, I'm collecting all the
quantities for a part number quote into an variable named "a". I have
a userform with a textbox and a command button. See the code I'm
using below.

I have two questions:

How can I save the variable for use in another sub?
How can I make sure the user doesn't click the command button until a
quantity is entered in the text box?

Thanks,

Dan
------------------------------------------------------------------
Private Sub cmdQuantity_Click()
Dim lr As Long, sh As Worksheet
Dim aQuant As Variant
Dim cont
Static a() As String
Dim lngArrayCounter As Integer

lngArrayCounter = -1
On Error Resume Next
lngArrayCounter = UBound(a)
On Error GoTo 0
If lngArrayCounter = -1 Then
ReDim Preserve a(0)
Else
ReDim Preserve a(lngArrayCounter + 1)
End If
a(UBound(a)) = txtQuantity_1.Text


cont = MsgBox("DO YOU NEED TO MAKE ANOTHER ENTRY?", vbYesNo,
"CONTINUE?")
If cont = vbYes Then
Me.txtQuantity_1.Text = ""
Me.txtQuantity_1.SetFocus
End If
End Sub
 
Reply With Quote
 
 
 
 
dan dungan
Guest
Posts: n/a
 
      1st Mar 2010
I neglected to show the sub I'm using to do the calculations.

Private Sub cmdCalc_Click()
'From: Dave Peterson <peter...@verizonXSPAM.net>
'Date: Thu, 25 Feb 2010 21:06:05 -0600

Dim sCoreAdapShell As String 'it's all text, right?
Dim res As Variant 'could be an error

sCoreAdapShell = txtCore.Text & txtAdap_Config.Text & txtShell.Text

res = Application.vLookup(sCoreAdapShell, _

ThisWorkbook.Worksheets("tblPriceListCorePart").Range("tblPriceListCore"),
_
5, False)

If IsError(res) Then
'like #n/a in excel
Me.txtShellEntrySum.Text = "not found!"
Else
Me.txtShellEntrySum.Value = res * Me.txtCore_Multiplier.Value
End If

End Sub
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Redimming an array dynamically assigned from range (how to redim first dimension of a 2-D array? /or/ reverse the original array order) Keith R Microsoft Excel Programming 3 13th Nov 2007 04:08 PM
Disallow PST file Kevin Microsoft Outlook 1 4th May 2007 10:26 AM
Disallow CTRL+ALT+DEL =?Utf-8?B?anV0bGF1eA==?= Microsoft Excel Programming 8 17th Nov 2006 06:10 PM
allow\disallow herbert Microsoft Access Getting Started 1 18th Apr 2005 01:33 PM
disallow access George Windows XP Hardware 0 5th Sep 2003 11:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:41 PM.