473,387 Members | 1,416 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

one button with alternative action

Hi all,

I am using visual studio, VB .net

i have a form with a "Support" button which may be pushed as often as
wished. If the current name is "result 1", then "result 2" should be
displayed in the text box. If the current name is "result 2", then
"result 1" will appear again.
I have tried the following

thanks in advance,
Static iStatus as integer
iStatus = abs(iStatus -1)
if iStatus=1 then
Field1.txt="result 2"
else
Field1.txt="result 1"
end if

the problem is the I get the error
name 'abs' is not declared

can anybody help, is above the right method at all?

greetings

Murt
Nov 20 '05 #1
5 1961
* "Murt" <Mu**********@ATyahoo.DOTcom> scripsit:
I am using visual studio, VB .net

i have a form with a "Support" button which may be pushed as often as
wished. If the current name is "result 1", then "result 2" should be
displayed in the text box. If the current name is "result 2", then
"result 1" will appear again.
I have tried the following

thanks in advance,
Static iStatus as integer
iStatus = abs(iStatus -1)
if iStatus=1 then
Field1.txt="result 2"
else
Field1.txt="result 1"
end if

the problem is the I get the error
name 'abs' is not declared


Use 'Math.Abs' instead. Make sure the 'System' namespace is imported.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
"Murt" <Mu**********@ATyahoo.DOTcom> schrieb
Hi all,

I am using visual studio, VB .net

i have a form with a "Support" button which may be pushed as often
as wished. If the current name is "result 1", then "result 2" should
be displayed in the text box. If the current name is "result 2",
then "result 1" will appear again.
I have tried the following

thanks in advance,
Static iStatus as integer
iStatus = abs(iStatus -1)
if iStatus=1 then
Field1.txt="result 2"
else
Field1.txt="result 1"
end if

the problem is the I get the error
name 'abs' is not declared
Probably "abs" is neither a local variable, nor a member of the class, nor a
member of the same or enclosing namespaces, nor a member of imported
namespaces/classes.

Use Math.Abs or System.Math.Abs

can anybody help, is above the right method at all?


Seems to be right. Alternatives:

istatus = (istatus+1) mod 2

- or -

static iStatus as boolean
iStatus = not iStatus
if iStatus then
field1.text = "result2"
else
field1.text = "result1"
end if
--
Armin
Nov 20 '05 #3
thanks Herfried,

that did the trick

Murt

Herfried K. Wagner [MVP] wrote:
* "Murt" <Mu**********@ATyahoo.DOTcom> scripsit:
I am using visual studio, VB .net

i have a form with a "Support" button which may be pushed as often as
wished. If the current name is "result 1", then "result 2" should be
displayed in the text box. If the current name is "result 2", then
"result 1" will appear again.
I have tried the following

thanks in advance,
Static iStatus as integer
iStatus = abs(iStatus -1)
if iStatus=1 then
Field1.txt="result 2"
else
Field1.txt="result 1"
end if

the problem is the I get the error
name 'abs' is not declared

Use 'Math.Abs' instead. Make sure the 'System' namespace is imported.


Nov 20 '05 #4
Hi Murt,

In cases where you <are> dealing with numbers, you can often look at
things the 'other way round'
iStatus = 1 - iStatus '0 then 1, then 0

I would use Armin's Boolean method myself - it's the clearest.

Regards,
Fergus

Nov 20 '05 #5
"Murt" <Mu**********@ATyahoo.DOTcom> wrote...

I see others have answered your first question and an alternative was
presented... I'll offer one more based on the idea that keeping track of a
boolean state to change a boolean state is probably not necessary. By that
I mean, if you happen to have a static boolean sitting around to indicate
the state of more than just the button text I'd probably use it (it really
is the "indicator" at that point) but if all it does is keep track of what
the text should look like there is a little point.

So you get:

if ( field1.text = "result1" ) then
field1.text = "result2"
else
field1.text = "result1"
end if

or my personal preference:

field1.text = iif(field1.text = "result1", "result2", "result1" )


Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Adrian | last post by:
I need to have 2 submit buttons in one form calling the same page. I just need to know which was used. Being able to pass a hidden form input for each would be ideal. How can I do this?? ...
5
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action...
20
by: Tammy | last post by:
What would be a good alternative to using frames? I need something that will section my webpage into two halves and can change both frames on a single click. Thanks in Advance, Tammy
3
by: Adam | last post by:
Hey guys, I've decided to stop banging my head against the wall and just ask you guys for the answer. I can't seem to find it. I have a form in which I have multiple submit buttons; only, I'm...
2
by: Les Juby | last post by:
I've used a simple javascript for some time (no entries required up in the <head> tag) that asks for a confirmation before deleting. ie. <a href="/delete.asp?which=345 %>"...
2
by: NishSF | last post by:
Would anyone have any suggestions/javascript code so that if one clicks the Radio Button "Yes" below he has the option of selecting any of the six CheckBox below. If the user clicks on Radio Button...
3
by: bluez | last post by:
I want to design a webpage where user can search the data from the database and list out the related records. Each of the record got a delete button which allow user to delete the record. ...
8
by: rahulnag22 | last post by:
I have created a button widget with a button click binding. The button initially has a state=disabled. I can see the greyed out version of the button in the GUI. But If I click on the button it...
2
by: rookiejavadude | last post by:
I'm have most of my java script done but can not figure out how to add a few buttons. I need to add a delete and add buttong to my existing java program. Not sure were to add it on how. Can anyone...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.