|
-
Aug 8th, 2000, 03:00 PM
#1
Thread Starter
Hyperactive Member
Hmmm.. I guess I'm too lazy to spend the needed time in browsing the the help files so here I am.
Stupid question I think, since I`ve done that millions of times in Access. But now in VB: I've succesfully created exclusive option buttons (2) on a form by creating them both in a frame.
To assign a value to these option buttons by code, in Access, all you had to do is give the frame a value (True or False), and the appropriate Option button would become clicked. In VB this just won't work.. what's the best way of doing this? I'm trying to avoid having 2 lines of code:
opt1.value = true
opt2.value = false
I'm sure you guys get the idea - thanks...
-
Aug 8th, 2000, 03:03 PM
#2
Lively Member
Set one to true, the other will automatically be set to false.
As in:
Opt1.value = true
-
Aug 8th, 2000, 03:14 PM
#3
Thread Starter
Hyperactive Member
Of course I've already tried this - that's how it works in Access.
But it doesn't work in VB. Setting opt1.value = False won't make opt2.value = True. Both of them will then be False. And I did check twice to make sure they're exclusive.
How can I fix that? Btw, they're both in a vb frame.
Thanks.
-
Aug 8th, 2000, 03:17 PM
#4
Frenzied Member
instead of making 1 of them false, make the other one true
NXSupport - Your one-stop source for computer help
-
Aug 8th, 2000, 03:18 PM
#5
transcendental analytic
You should make your optionbuttons an array so that you can easyly set the first index to true
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 8th, 2000, 03:29 PM
#6
You can combine lines with a semicolon so it will appear as one.
Code:
Option1.Value = True: Option2.Value = False
-
Aug 8th, 2000, 03:33 PM
#7
Thread Starter
Hyperactive Member
dimava: Yes, but that way, I need 2 lines of code. Let's say I'm making a lookup from a database, the code would look like this:
opt1.value = iif(dbfield = "Male";True;False)
This sets the option value in only one line of code. Do you understand what I mean by that? In access, if dbfield is "Female", the opt2.value will automatically be set to true by setting opt1.value to false. You may find it a bit exagerated to save only one line of code but I really believe that, for some reasons, I do need that.
kedaman: Will using an array let me fix the problem described above?
Thanks to you guys
-
Aug 8th, 2000, 03:39 PM
#8
Frenzied Member
why do you need to lines of code
[code]
(bold means checked)
O Male
O FeMale
'to get that then you write
optMale.value = true
'and the other will automaticly become un checked
Code:
O Male
O FeMale
'to get that then you write
optFeMale.value = true
'and the otehr will automaticly become un checked
NXSupport - Your one-stop source for computer help
-
Aug 8th, 2000, 03:47 PM
#9
Thread Starter
Hyperactive Member
I'm beginning to give up on my one line of code idea, just like access could do it using a frame.
dimava, it does take 2 lines of code or.. I dunno, an IF, to evaluate which option button I must set to true. you understand? If not, try coding it I know it takes one line to set an option button to true but what I was saying is that in Access, you can always set the value on the first option button (true OR false), and the other one will react accordingly. This was done on one line. (I know I can put 20 lines of code on only one line, using ":") 
Anyway I see it's not possible in VB, I'm giving up, gonna do something like:
if dbfield = "Male" then
opt1.value = true: opt2.value = false
else
opt1.value = false: opt2.value = true
end if
voila.
-
Aug 8th, 2000, 03:51 PM
#10
Frenzied Member
what you are trying to do is gonna take up 2 lines (at least)
Code:
if dbfield = "male" then
opt1.value = true
else opt2.value = true
NXSupport - Your one-stop source for computer help
-
Aug 8th, 2000, 03:52 PM
#11
Thread Starter
Hyperactive Member
Yes that would be more like it.. my code exemple was written on the fly...
...still wonder why they didn't to it like in access tho.
-
Aug 8th, 2000, 04:55 PM
#12
transcendental analytic
Using an array you could have one line
Code:
opt1(-(dbfield = "male"))=true
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|