Assume that the currently selected item is S (a line in the list box).
1, number each dish, such as: 0 1- boiled fish, 02- kung pao chicken ... use an array (such as arrPrice) to save the price, index the corresponding numbers, and get the price:
P = arrPrice(val(Mid(s, 1, 2))' The default number here is 2 digits, that is, up to 99 kinds of dishes, which can be extended.
Just calculate all the selected prices.
2. The list box has an attribute ItemData(Index), which can store extra numbers (integers). If you use this attribute to save the price, you don't need numbers (or arrays). When ordering, copy the attribute and calculate its value.
List 1。 AddItem "Boiled Fish-40 yuan"
list 1。 ItemData(0)=40
..
3. Of course, you can also extract the price in the current format, which requires analyzing the string. For reverse string, the last "-"and "yuan" are the price.
S2 = strverse (s)' inverts the string, that is, "123" becomes "32 1".
NPos = Instr(s2, "-"'Find the first "-",because it is inverted, it is the last "-"in the original string.
If nPos & gt. 0 and then p = val (STRREVERSE (MID (S2, 2, NPOS-2))' to get the price, and then turn it into a number.
If the price format is fixed (such as fixed 2 digits), it can be simplified to one sentence:
p = mid(s,len(s)-2,2)