View unanswered posts | View active topics
It is currently Sun May 18, 2025 9:54 pm
|
Page 1 of 1
|
[ 12 posts ] |
|
Visual Basic 2010 question about displaying data in a form
Author |
Message |
John_Vella
I haven't seen my friends in so long
Joined: Fri Apr 24, 2009 7:55 am Posts: 7935 Location: Manchester.
|

Hi, OK, I'm not exactly sure how to describt this but I'll try anyway... I'm writing an application using Visual Basic 2010, and I have 2 sets of Radio buttons. I have gotten as far as being able to select a button in each set, and that in turn sets a variable to a value depending on which button is selected. I should point out that I click a button to perform the calculation, which is what I want... What I need is a way to have those values displayed somewhere on the screen. I have managed to create a message box with the data displayed, but I want the data on the screen, as I will be re-using the variable for something else... Here are some code snippets, if it helps... This is where I set the variables, (some of which are no longer needed, but I'll remove them later) I have one of these set up for each radio button, and yes I know that there is probably a far easier way, but I'll refine the code after I get the damned thing working! By the way, I also use the same sort of code to assign a value to ssval As I said, I can get the value, (expo1) to appear in a message box, but I want it to appear on the scree... Any ideas, (while I carry on searching)? Thanks in advance, John. 
_________________John Vella BSc (Hons), PGCE - Still the official forum prankster and crude remarker  Sorry  I'll behave now. Promise 
|
Fri Sep 10, 2010 7:45 pm |
|
 |
forquare1
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:36 pm Posts: 5150 Location: /dev/tty0
|
As an incomplete answer: I think I'd use a label and then do something like:
|
Sat Sep 11, 2010 9:18 am |
|
 |
John_Vella
I haven't seen my friends in so long
Joined: Fri Apr 24, 2009 7:55 am Posts: 7935 Location: Manchester.
|
Hmmm... interesting... I thought that the second command was Java, or am I losing the plot? Again  OK, I'll give it a go in a little while, once the PC has finished a fairly major encoding job and let you know how I get on. Thanks. 
_________________John Vella BSc (Hons), PGCE - Still the official forum prankster and crude remarker  Sorry  I'll behave now. Promise 
|
Sat Sep 11, 2010 10:06 am |
|
 |
big_D
What's a life?
Joined: Thu Apr 23, 2009 8:25 pm Posts: 10691 Location: Bramsche
|
That is Java, not VB...
The VB would be:
expo1 = ndval * ssval mylabel.text = expo1
_________________ "Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari
Executive Producer No Agenda Show 246
|
Sat Sep 11, 2010 3:43 pm |
|
 |
forquare1
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:36 pm Posts: 5150 Location: /dev/tty0
|
Aye, I knew Java did it, but I though that VB would be similar, at least similar enough to get you on the right tracks 
|
Sat Sep 11, 2010 4:53 pm |
|
 |
John_Vella
I haven't seen my friends in so long
Joined: Fri Apr 24, 2009 7:55 am Posts: 7935 Location: Manchester.
|
Thanks guys. Ben, it din indeed put me on the right tracks, and Dave thanks also, for saving me a bit more searching. It's coming along quite nicely now... 
_________________John Vella BSc (Hons), PGCE - Still the official forum prankster and crude remarker  Sorry  I'll behave now. Promise 
|
Sat Sep 11, 2010 10:01 pm |
|
 |
John_Vella
I haven't seen my friends in so long
Joined: Fri Apr 24, 2009 7:55 am Posts: 7935 Location: Manchester.
|
OK, update time... I had to leave this project alone for a while, but I'm finding it's a nice distraction for when I need to stop doing college/uni work for 10 minutes, but I've hit another road block. I need a way of making a variable available in different forms. The variable in question is expo1, and it is dynamically updated with a value, but when I click a button which opens a new form I can't get the value to carry across. I've tried Googling it, but nothing I've seen has helped... Any bright ideas please? TIA 
_________________John Vella BSc (Hons), PGCE - Still the official forum prankster and crude remarker  Sorry  I'll behave now. Promise 
|
Tue Jan 18, 2011 8:35 pm |
|
 |
JJW009
I haven't seen my friends in so long
Joined: Thu Apr 23, 2009 6:58 pm Posts: 8767 Location: behind the sofa
|
If you want a variable to be global across all forms in a project, then you need to add a new module and define it in that. Variables defined in a form can only be used in that form. I think 
_________________jonbwfc's law: "In any forum thread someone will, no matter what the subject, mention Firefly." When you're feeling too silly for x404, youRwired.net
|
Wed Jan 19, 2011 12:18 am |
|
 |
John_Vella
I haven't seen my friends in so long
Joined: Fri Apr 24, 2009 7:55 am Posts: 7935 Location: Manchester.
|
After I added the module and removed the variables from the individual forms it worked a treat, so thanks a million JJ! 
_________________John Vella BSc (Hons), PGCE - Still the official forum prankster and crude remarker  Sorry  I'll behave now. Promise 
|
Wed Jan 19, 2011 9:11 am |
|
 |
finlay666
Spends far too much time on here
Joined: Thu Apr 23, 2009 9:40 pm Posts: 4876 Location: Newcastle
|
Easiest way is a global (if vb supports it) OR Pass it via the method that opens the form I'd say
_________________TwitterCharlie Brooker: Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.
|
Wed Jan 19, 2011 9:03 pm |
|
 |
John_Vella
I haven't seen my friends in so long
Joined: Fri Apr 24, 2009 7:55 am Posts: 7935 Location: Manchester.
|
Thanks Fin. JJ's method did work, but I'll give the global variables a go as well... always nice to have a few different ways of doing the same thing.
Now all I need to do is find the time to code a countdown timer, (after converting seconds into hours minutes and seconds)
_________________John Vella BSc (Hons), PGCE - Still the official forum prankster and crude remarker  Sorry  I'll behave now. Promise 
|
Thu Jan 20, 2011 9:33 am |
|
 |
finlay666
Spends far too much time on here
Joined: Thu Apr 23, 2009 9:40 pm Posts: 4876 Location: Newcastle
|
easier to make use of an initial datetime and getting the timespan instead. then you can calculate the difference then convert them (eg seconds = hours * 360)
_________________TwitterCharlie Brooker: Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.
|
Thu Jan 20, 2011 4:30 pm |
|
|
|
Page 1 of 1
|
[ 12 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 7 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum
|
|