saschamps9903
Thu Jan 13 22:33:05 CST 2005
Thanks Greg, it worked but I don't understand how. If you look at the
original code, my problem seemed to come when I got to "MsgBox Prompt" and so
on through the code. From first Dim to the prompt of type the second
integer, it was working perfectly. I changed the code back to the original
way it was written except I left your change where A:=intFirstNumber,
B:=intSecondNumber and it worked. As someone who is just starting to dip
their toe in the VBA waters, could you recommend any reading material that
will help me learn VBA?
"Greg Maxey" wrote:
> Mike,
>
> Hard to say exactly what you are doing wrong without seeing your code. The
> problem with posting your code is that it sometimes doesn't look the same on
> both ends. I pasted the code from the site you mentioned and abbreviated it
> some in hopes that each line of execution will fit on one line. I mostly
> just substitued shorter terms. Note I also changed integer throughout to
> Double. While the example you provide will return 2+2=4 it will also return
> 2.1+2.1=4. Double is just a different data type that will provide better
> results. See if you can paste the following in your VBA editor and get it
> to work.
>
> Sub CallAR()
>
> Dim iFN As Double 'instead of integer
> Dim iSN As Double 'instead of integer
> iFN = InputBox(Prompt:="Type the first number.")
> iSN = InputBox(Prompt:="Type the second number.")
> MsgBox Prompt:=iFN & " + " & iSN & " = " & AR(A:=iFN, B:=iSN)
>
> End Sub
>
> Public Function AR(ByVal A As Double, ByVal B As Double) As Double
> AR = A + B
> End Function
>
>
> --
> Greg Maxey/Word MVP
> A Peer in Peer to Peer Support
>
> mikeyj wrote:
> > Hello, I am just starting out trying to learn a little VBA code and
> > was trying to understand an example at the following address:
> >
> >
http://office.microsoft.com/en-us/assistance/HA010188011033.aspx
> >
> > I typed the code as requested but I am receiving the following error:
> >
> > "Compile Error, sub or function not defined"
> >
> > the hilighted area points to the word "AdditionResult". I am not
> > sure how to make it work. I tried typing it carefully a couple of
> > different ways and even just copied the code directly from the
> > webpage, but it will not work. what am I doing wrong?
>
>
>