Dice Notation in excel, get minimal value -
(
With the help of a few friends I have made it: It takes expression in standard dice signage And gives fewer results.
Public function rollin (such as range range) as the variant application. Voltage diem v string, new form in the form of string, form of demoda boolean dim de In the string dice = "D" gluta = False dicemode = False v = r.Value NewForm = "=" I = 1 lane (v) ch = mid (v, I, 1) if ch = Then again NewForm = NewForm & amp; "*" dicemode = True Glute = true if if notumeric (ch) and dicemode then dicemode = false newform = newform & end if if glute then ch = "1" glute = false End if NewForm = NewForm & Evaluation (NewForm)
End Function
When I feed it with 1D
if I give it 1d4 + 4, I get 1 * 1 + 4 = 5
Here's my problem, when I call it D10, D12, D20 or D1 1 (or 1 digit) No dice with more than) It will only take the first number. Given 1d12 + 2, this 1 * 12 + 2 will give 1 * 14 + 2, given 1d14 + 2.
I need that "d" and the next operating sign +, -, / /
I tried to modify it in many ways but it can not be done to take all the digits between the D and the next operator, it always does not take anything else first and then adds the other points.
To be precise, I have to assess the minimum value for any dyed expression in my function. Looking at XdY + Z, this X * 1 + Z, XdY + 2 + XdZ will be given, it will be X * 1 + 2 + X * 1.
Thanks in advance.
Edit 1:
By doing this:
Public Function Rollin (as Range Range) as the Variant Application. In the form of a voltage diem v string, as a newform string, string dice as dim D in the form of demoda boolean = "d" glute = False dicemode = False v = r.Value NewForm = "=" I = 1 Lane (v) ch = mid (v, i, 1) if ch = dice then newform = newfarm & amp; "*" Dichemode = True Glut = True Else if Nonmirtic (CA) and DCmode then DCmode = Falls Newform = NewForm & amp; "1+" end if glutti occurs then f = "1" glut = false and if induumeric (ca) is not deded then newform = newform & amp; "+" & Amp; F & end and if next I rollin = (newform) and function
This works but there are many ++ expressions but it can not stop it from working well but I Want to know how to avoid it ...
Editing 2: No, it does not work.
Editing 3: Can the split function have many delimiters? Edit this post: This post was reviewed and commented in my comment: "Comment: RPG tag has been removed because this question has nothing to do with RPG language" Dice notation Is used only in RPG (Roleplaying Games), I was not discussing again in the IBM / RPG language.
This should do what should:
public function Long Dim SplitByPlus in the form of rollman (Bevel Dice String in the form of string), as 'Example 1d14 + 2 + 5d13' split the split strings into all the extra partsPlleplus = Split (dicestrings, "+") SplitBillPlus now Array (1d14, 2,5d13) is dim, I loop 'lengthy' and 'i' = lbound (splitByPlus) through each element of 'sir' Litbiples adds the current number to Rollmin = Rollmin + Split (splitB YPlus (i), "d") (0) 'split first 1d14 (1, 14) and the first element is added' seconds 2 Is divided by (2) and the first element (2) adds 'the third 5d13 is divided (5, 13) and the first element (5) is added' rollin now 1 + 2 + 5 end function Edit
Edit: OK, modifying my solution is not that easy. Instead, use it:
Public function rollmin (bevel dice string in the form of string) slow as long as I have long-dimensional conversion as string dim current In the form of a string for string, I = 1 should be the Len (diceString) currentCharacter = Mid (diasstrings, I, 1) if the current character = "D" then 'D and all the following numbers I & lt; Lane (Duststring) and Ezenumaric (Mid (Duststrings, I + 1,1)) i = i + 1 Vend Other Conversion Formula = Changed Formula & amp; Existing character end if next rollman = evaluation ("=" and converted formula) and function
Comments
Post a Comment