2016-07-08 2 views
-2

안녕하세요 어떻게 바텐더 VB 스크립트에서 아래의 로직을 구현할 수 있습니까? X=33, " "=38, V=31, L=21 + 1 + 8 + 38 + 31 + 21 + 4 + 0 + 1 + 9 + 7 + 3 + 6 + 6 = 168바텐더 레이블 VB 스크립트에서 문자열에 숫자를 추가하는 방법

X18 VL40197366 = 33.

이제 위 결과는 temp1이라는 변수에 저장됩니다. 여기서 temp1에는 now = 168이 포함됩니다. `temp1 = 168``

내 코드는 아래에 있습니다. 내 코드가 완전하지 않다는 것을 알고있다. 내가 틀렸다면 나를 바로 잡아라.

Dim A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z 
A = 10 
B=11 
C=12 
D=13 
E=14 
F=15 
G=16 
H=17 
I=18 
J=19 
K=20 
L=21 
M=22 
N=23 
O=24 
P=25 
Q=26 
R=27 
S=28 
T=29 
U=30 
V=31 
W=32 
X=33 
Y=34 
Z=35 
'Here i don't know how to declare the values for special characters and number 
'I need to assign, if my final result is 0,...to 9, i need 0 to 9 as result. 
'In addition to that, if my final result is 36, 37, 38, 39, 40, 41, 42, I need to show the corresponding symbols - . "" $/+ % 

Dim temp1,temp3,temp4,temp5,temp6, temp7, temp8 
float temp2 

temp4 = Format.Objects("Text 1").Value 'Here i input first three characters depending on user input, ex:X18 
'how can i give a check option here to add the above text , for ex, i need the result called 33+1+8 to be stored 
'I have syntax called IIF(ConditionalExpr, ExprIfTrue, ExprIfFalse) 

temp5= Format.Objects("Text 2").Value 'Here i input second three characters depending on user inputer, this is the characters after the space ex:VL4 
    'same here too, 

temp6= Format.Objects("Text 3").Value 'Here i input third 7 characters depending on user inputer, ex:0197366 
    'same here too, 

temp7 = 38 'this variable is for the space always this is constant 

'temp1=temp4+temp7+temp5+temp6'but this code is giving me result called X1838VL40197366, which is incorrect. I need to be like shown as below 
temp1= "" 'should hold the addition of all above for ex: 33+1+8+38+31+21+4+0+1+9+7+3+6+6=168 

이것을 실행하는 방법! 사전에 모든

+0

은 [요청]. – Enigmativity

+0

하지만 제발 처음이에요, 미안 해요, 제발 용서해주십시오 –

+0

도움이 사람 !!! –

답변

0

최초의

덕분에, 나는 분명 당신이 뭘하려는 건지 이해가 안 돼요.

하지만, 귀하의 경우에는 개별 변수를 선언하는 대신 Dictionary 클래스를 사용해야합니다.

Dim dicResult as new Dictionary(Of String, Decimal) 
Dim arrSymballs() As String = {"A","B","C","D","E","F","G","H","I"} ''You can add more 
Dim iValue As Decimal = 10 
For i As Integer = 0 To arrSymballs.Length-1 
    dicResult.Add(arrSymballs(i), iValue) 
    iValue += 1 
Next 

''Function to get string from result 
''I don't know how the result you will get the following logic is for "10,11,12,13,14,15" 
Private Function getResultString(_result As String) As Decimal 
    Dim dNumResult As Decimal 
    For Each c As String in _result.Split(",") 
     dNumResult += dicResult(c) 
    Next 
    Return dNumResult 
End Function 
+0

쉘 감사하지만, 선언 된 변수 값을 제공하는 방법 ?? –

+0

바텐더 프로그래머에 문제가 있습니다. 위와 같이 줄 수 없으므로'OnAutoSelectedEvent (Line 3) '으로 오류가 발생합니다. Dim dicResult as new Decimal (Of String, Decimal) : 기대되는 명령문의 끝' –

+0

하시기 바랍니다. ... ?? –

0

변수를 숫자 유형으로 선언하지 않았습니다. 컴파일러는 Format이 문자열을 반환하기 때문에 문자열을 사용하기를 원하는 것으로 추측합니다. 문자열 값을 숫자 값으로 변환해야합니다.

Integer.Parse (텍스트)

temp6 = Integer.Parse(temp5) + x 

당신은 많은 변수가있을 때 배열을 사용하는 것이 좋습니다.

Dim iValues As Integer() = New Integer() {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35} 

temp6 = Integer.Parse (temp5) + 당신은 읽어야 iValues ​​(24)

+0

문제는 바텐더 프로그래머에서 위와 같이 표현할 수 없습니다. OnAutoSelectedEvent (Line 2)로 오류가 발생합니다. Dim iValues ​​As Integer() = 새 정수() {10, 11, 12, 13, 14, 15, 16 , 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35} –

관련 문제