Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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
Hi Manish
Manish the solution you gave worked,Thank you sooo much
Regrds
Sikandar