Home All Groups Group Topic Archive Search About
Author
21 Sep 2005 9:10 AM
Dave
Hi

Can you help with the following problem

Msgbox("Do you wish to add " & rstSpread.Fields(4) & " to your nett prices
for this supplier?", vbYesNo, "Add New Material") As Boolean

I am trying to get the variable rstSpread.fields(4) to appear in the
messagebox but i think there is a problem in the syntax to do with the
quotation marks.  Any ideas?

Also when i receive the reply of yes or no, how can i construct an if
statement from it?  Is it simply If vbYesNo = 1 then ....

Thanks

Author
21 Sep 2005 9:33 AM
Martin
e.g.
If MsgBox("Do you want to discard all changes ?", vbYesNo, Me.Caption) =
vbYes Then
or use a Select Case


Show quoteHide quote
"Dave" <d***@dave.com> schreef in bericht
news:43312371$0$17504$ed2e19e4@ptn-nntp-reader04.plus.net...
> Hi
>
> Can you help with the following problem
>
>  Msgbox("Do you wish to add " & rstSpread.Fields(4) & " to your nett
prices
> for this supplier?", vbYesNo, "Add New Material") As Boolean
>
> I am trying to get the variable rstSpread.fields(4) to appear in the
> messagebox but i think there is a problem in the syntax to do with the
> quotation marks.  Any ideas?
>
> Also when i receive the reply of yes or no, how can i construct an if
> statement from it?  Is it simply If vbYesNo = 1 then ....
>
> Thanks
>
>
Author
21 Sep 2005 9:35 AM
J French
On Wed, 21 Sep 2005 10:10:16 +0100, "Dave" <d***@dave.com> wrote:

>Hi
>
>Can you help with the following problem
>
> Msgbox("Do you wish to add " & rstSpread.Fields(4) & " to your nett prices
>for this supplier?", vbYesNo, "Add New Material") As Boolean

>I am trying to get the variable rstSpread.fields(4) to appear in the
>messagebox but i think there is a problem in the syntax to do with the
>quotation marks.  Any ideas?

No it is nothing to do with quotation marks

>Also when i receive the reply of yes or no, how can i construct an if
>statement from it?  Is it simply If vbYesNo = 1 then ....

If MsgBox( "Some Prompt", vbYesNo, "Some Caption" ) = vbYes Then

MsgBox is a function
- it returns a number not a Boolean

The second parameter (vbYesNo) is a constant telling it what buttons
to display and what icon
- it does not get modified
Author
21 Sep 2005 4:31 PM
Someone
> If MsgBox( "Some Prompt", vbYesNo, "Some Caption" ) = vbYes Then

Or if the line is too long:

If vbYes = MsgBox( "Some Prompt", vbYesNo, "Some Caption" ) Then

So you don't have to scroll all the way to the right...



Show quoteHide quote
"J French" <erew***@nowhere.uk> wrote in message
news:4331287d.91039674@news.btopenworld.com...
> On Wed, 21 Sep 2005 10:10:16 +0100, "Dave" <d***@dave.com> wrote:
>
>>Hi
>>
>>Can you help with the following problem
>>
>> Msgbox("Do you wish to add " & rstSpread.Fields(4) & " to your nett
>> prices
>>for this supplier?", vbYesNo, "Add New Material") As Boolean
>
>>I am trying to get the variable rstSpread.fields(4) to appear in the
>>messagebox but i think there is a problem in the syntax to do with the
>>quotation marks.  Any ideas?
>
> No it is nothing to do with quotation marks
>
>>Also when i receive the reply of yes or no, how can i construct an if
>>statement from it?  Is it simply If vbYesNo = 1 then ....
>
> If MsgBox( "Some Prompt", vbYesNo, "Some Caption" ) = vbYes Then
>
> MsgBox is a function
> - it returns a number not a Boolean
>
> The second parameter (vbYesNo) is a constant telling it what buttons
> to display and what icon
> - it does not get modified
Author
21 Sep 2005 10:28 AM
Steve Barnett
Is yo ur MsgBoxc on a single line or have you split it (as shown in the
post). If you've split it, then the syntax is wrong... try:

Msgbox("Do you wish to add " & rstSpread.Fields(4) & _
    " to your nett prices  for this supplier?", vbYesNo, "Add New Material")

Also, what's the "As Boolean" doing on the end? You can't specify the return
type on the end of a statement in this way. MsgBox returns "VBMsgBoxResult"
so your code should be along the lines:

Dim nReply as VBMsgBoxResult

    nReply = Msgbox("Do you wish to add " & rstSpread.Fields(4) & _
        " to your nett prices  for this supplier?", vbYesNo, "Add New
Material")
    if nReply  = vbYes then
        '*** Do stuff for yes
    else
        '*** Do stuff for no
    end if


HTH
Steve



Show quoteHide quote
"Dave" <d***@dave.com> wrote in message
news:43312371$0$17504$ed2e19e4@ptn-nntp-reader04.plus.net...
> Hi
>
> Can you help with the following problem
>
> Msgbox("Do you wish to add " & rstSpread.Fields(4) & " to your nett prices
> for this supplier?", vbYesNo, "Add New Material") As Boolean
>
> I am trying to get the variable rstSpread.fields(4) to appear in the
> messagebox but i think there is a problem in the syntax to do with the
> quotation marks.  Any ideas?
>
> Also when i receive the reply of yes or no, how can i construct an if
> statement from it?  Is it simply If vbYesNo = 1 then ....
>
> Thanks
>
Author
21 Sep 2005 1:51 PM
Jeff Johnson [MVP: VB]
"Steve Barnett" <non***@nodomain.com> wrote in message
news:O1fSucpvFHA.2292@TK2MSFTNGP12.phx.gbl...

> Is yo ur MsgBoxc on a single line or have you split it (as shown in the
> post). If you've split it, then the syntax is wrong... try:
>
> Msgbox("Do you wish to add " & rstSpread.Fields(4) & _
>    " to your nett prices  for this supplier?", vbYesNo, "Add New
> Material")

By itself this is also incorrect. To call MsgBox in a standalone manner
you'd need to drop the parentheses:

    Msgbox "Do you wish to add " & rstSpread.Fields(4) & _
        " to your nett prices  for this supplier?", vbYesNo, "Add New
Material"

Of course then there would be no way to get the return value; if what you
posted were part of an If/Then statement then it would be correct.
Author
21 Sep 2005 1:53 PM
alpine
Show quote Hide quote
On Wed, 21 Sep 2005 10:10:16 +0100, "Dave" <d***@dave.com> wrote:

>Hi
>
>Can you help with the following problem
>
> Msgbox("Do you wish to add " & rstSpread.Fields(4) & " to your nett prices
>for this supplier?", vbYesNo, "Add New Material") As Boolean
>
>I am trying to get the variable rstSpread.fields(4) to appear in the
>messagebox but i think there is a problem in the syntax to do with the
>quotation marks.  Any ideas?
>
>Also when i receive the reply of yes or no, how can i construct an if
>statement from it?  Is it simply If vbYesNo = 1 then ....
>
>Thanks


For your conditional statement, you can use either If...Then or Select
Case syntax.  They would look like these....

  If Msgbox("Do you wish to add " & rstSpread.Fields(4) _
            & " to your net prices for this supplier?", _
                                    vbYesNo, "Add New Material") Then

  End if

  Select Case Msgbox("Do you wish to add " & rstSpread.Fields(4) _
            & " to your net prices for this supplier?", _
                                    vbYesNo, "Add New Material")

    Case vbYes

    Case vbNo

  End select


When you refer to "question marks" with regards to
rstSpread.fields(4), I suspect what you mean is that the field is ANSI
text and needs to be converted to unicode in order to be displayed.
If that is indeed what is happening, you should be able to convert it
using the StrConv function like so....

  StrConv(rstSpread.fields(4), vbUnicode)

If that is not what you are referring to, you'll need to further
explain what your problem is.

HTH,
Bryan
____________________________________________________________
New Vision Software                   "When the going gets weird,"
Bryan Stafford                      "the weird turn pro."
alpine_don'tsendspam@mvps.org     Hunter S. Thompson - 
Microsoft MVP-Visual Basic     Fear and Loathing in LasVegas
Author
21 Sep 2005 2:44 PM
Jeff Johnson [MVP: VB]
"alpine" <alpine_don'tsendspam@mvps.org> wrote in message
news:51p2j1l5lev7icdd99a8qpcggu6h5phoha@4ax.com...

> When you refer to "question marks" with regards to
> rstSpread.fields(4), I suspect what you mean is that the field is ANSI
> text and needs to be converted to unicode in order to be displayed.

Actually, he said "quotation marks."
Author
21 Sep 2005 3:12 PM
alpine
Man!  I should have had that second cup of coffee *before* reading the
newsgroups!  ;-)

Bryan
____________________________________________________________
New Vision Software                   "When the going gets weird,"
Bryan Stafford                      "the weird turn pro."
alpine_don'tsendspam@mvps.org     Hunter S. Thompson - 
Microsoft MVP-Visual Basic     Fear and Loathing in LasVegas


On Wed, 21 Sep 2005 10:44:24 -0400, "Jeff Johnson [MVP: VB]"
<i.get@enough.spam> wrote:

Show quoteHide quote
>
>"alpine" <alpine_don'tsendspam@mvps.org> wrote in message
>news:51p2j1l5lev7icdd99a8qpcggu6h5phoha@4ax.com...
>
>> When you refer to "question marks" with regards to
>> rstSpread.fields(4), I suspect what you mean is that the field is ANSI
>> text and needs to be converted to unicode in order to be displayed.
>
>Actually, he said "quotation marks."
>
Author
21 Sep 2005 2:46 PM
Bob Butler
"alpine" <alpine_don'tsendspam@mvps.org> wrote in message
news:51p2j1l5lev7icdd99a8qpcggu6h5phoha@4ax.com
> For your conditional statement, you can use either If...Then or Select
> Case syntax.  They would look like these....
>
>   If Msgbox("Do you wish to add " & rstSpread.Fields(4) _
>             & " to your net prices for this supplier?", _
>                                     vbYesNo, "Add New Material") Then

Methinks you need an "= vbYes" or "= vbNo" in there.  As it stands the above
is always true.

--
Reply to the group so all can participate
VB.Net: "Fool me once..."
Author
21 Sep 2005 3:11 PM
alpine
Good catch.  I was thinking about the Select Case syntax and forgot to
add vbYes to the If...Then.

Bryan
____________________________________________________________
New Vision Software                   "When the going gets weird,"
Bryan Stafford                      "the weird turn pro."
alpine_don'tsendspam@mvps.org     Hunter S. Thompson - 
Microsoft MVP-Visual Basic     Fear and Loathing in LasVegas


On Wed, 21 Sep 2005 07:46:44 -0700, "Bob Butler"
<tiredofit@nospam.com> wrote:

Show quoteHide quote
>"alpine" <alpine_don'tsendspam@mvps.org> wrote in message
>news:51p2j1l5lev7icdd99a8qpcggu6h5phoha@4ax.com
>> For your conditional statement, you can use either If...Then or Select
>> Case syntax.  They would look like these....
>>
>>   If Msgbox("Do you wish to add " & rstSpread.Fields(4) _
>>             & " to your net prices for this supplier?", _
>>                                     vbYesNo, "Add New Material") Then
>
>Methinks you need an "= vbYes" or "= vbNo" in there.  As it stands the above
>is always true.
Author
21 Sep 2005 3:48 PM
Rick Rothstein [MVP - Visual Basic]
> > For your conditional statement, you can use either If...Then
or Select
> > Case syntax.  They would look like these....
> >
> >   If Msgbox("Do you wish to add " & rstSpread.Fields(4) _
> >             & " to your net prices for this supplier?", _
> >                                     vbYesNo, "Add New
Material") Then
>
> Methinks you need an "= vbYes" or "= vbNo" in there.  As it
stands the above
> is always true.

Or just tack on a -7 (minus seven) <g>

Rick