Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Condition Proble.

Hi

I m having a problem in writing a macro here.I have two variables name My Budget and Total Sale.In Mybudget i have assign it a value 8000.and in totalSale the value is 69950(sum of some expression).then i use a two msg box to show each value .it is showing the right value.then i use a conditon that if the value of total sale which is 69950 is less than 8000 then show a msg box which says my sales are less else msg box show that my Sales are greater.The right answere is that it has to show my sales are greater but it is showing My sales are lesss.i dont know y ....here is my Script

Sub ShowPoPUp

set a=ActiveDocument.Variables("MyBudget")

set v=ActiveDocument.Variables("TotalSale")

Msgbox(a.getcontent.string)

Msgbox(v.getcontent.string)

if ((v.getcontent.string) < (a.getcontent.string)) then

MsgBox ("MySales are less than 8000")

else

MsgBox ("MySales are greater than 8000")

end if

end Sub

1 Solution

Accepted Solutions
manishkumar75
Partner - Creator II
Partner - Creator II

Hi Sikandar,

Actually the problem is in Comparing the Values. You are comparing two string values, which is actually a numeric. I have modified the function.

Sub ShowPoPUp
Dim a,v
set a=ActiveDocument.Variables("MyBudget")

set v=ActiveDocument.Variables("TotalSale")

Msgbox(a.getcontent.string)

Msgbox(v.getcontent.string)

if (CLng(v.getcontent.string) < CLng(a.getcontent.string)) then
MsgBox ("MySales are less than 8000")

else

MsgBox ("MySales are greater than 8000")

end if

end Sub

Hope it will work.

- Manish

View solution in original post

2 Replies
manishkumar75
Partner - Creator II
Partner - Creator II

Hi Sikandar,

Actually the problem is in Comparing the Values. You are comparing two string values, which is actually a numeric. I have modified the function.

Sub ShowPoPUp
Dim a,v
set a=ActiveDocument.Variables("MyBudget")

set v=ActiveDocument.Variables("TotalSale")

Msgbox(a.getcontent.string)

Msgbox(v.getcontent.string)

if (CLng(v.getcontent.string) < CLng(a.getcontent.string)) then
MsgBox ("MySales are less than 8000")

else

MsgBox ("MySales are greater than 8000")

end if

end Sub

Hope it will work.

- Manish

Not applicable
Author

Hi Manish

Manish the solution you gave worked,Thank you sooo much

Regrds

Sikandar