Have you already taken a look at the shipping estimator? It may be exactly what you're looking to do. You could also use the token (!NUM_CART_ITEMS!) to get an integer representing the number of items in the cart (though normally this would be used for display on the site rather than calculations...hence the skin token format) or programmatically you could pass the CustomerID and the CartType to the ShoppingCart.NumItems method
Code:
ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.ShoppingCart)
to get an integer value back representing the number of items in the cart.
<a href="http://www.aspdotnetstorefront.com">Shopping Cart Software</a>