|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
msgbox problemHi
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 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 > > On Wed, 21 Sep 2005 10:10:16 +0100, "Dave" <d***@dave.com> wrote: No it is nothing to do with quotation marks>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 If MsgBox( "Some Prompt", vbYesNo, "Some Caption" ) = vbYes Then>statement from it? Is it simply If vbYesNo = 1 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 > 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 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 > "Steve Barnett" <non***@nodomain.com> wrote in message By itself this is also incorrect. To call MsgBox in a standalone manner 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") 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.
Show quote
Hide quote
On Wed, 21 Sep 2005 10:10:16 +0100, "Dave" <d***@dave.com> wrote: For your conditional statement, you can use either If...Then or Select>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 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 "alpine" <alpine_don'tsendspam@mvps.org> wrote in message Actually, he said "quotation marks."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. 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." > "alpine" <alpine_don'tsendspam@mvps.org> wrote in message Methinks you need an "= vbYes" or "= vbNo" in there. As it stands the abovenews: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 is always true. -- Reply to the group so all can participate VB.Net: "Fool me once..." 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. > > For your conditional statement, you can use either If...Then stands the aboveor 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 > is always true. Or just tack on a -7 (minus seven) <g>Rick
Fluctuation of printer alignment
Database and report question Newbie: How to extract year from a Date object VB6 : Attach Event Handlers to Dynamically Generated Controls How can i make sure List all jpg files from folder (loop problem) Random first random number delete Missing File Export Template in VB.NET about renaming the table .. |
|||||||||||||||||||||||