x404.co.uk http://www.x404.co.uk/forum/ |
|
Visual Basic 2010 question about displaying data in a form http://www.x404.co.uk/forum/viewtopic.php?f=4&t=10507 |
Page 1 of 1 |
Author: | John_Vella [ Fri Sep 10, 2010 7:45 pm ] | |||||||||||||||||||||||||||
Post subject: | Visual Basic 2010 question about displaying data in a form | |||||||||||||||||||||||||||
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. ![]() |
Author: | forquare1 [ Sat Sep 11, 2010 9:18 am ] | |||||||||
Post subject: | Re: Visual Basic 2010 question about displaying data in a form | |||||||||
As an incomplete answer: I think I'd use a label and then do something like:
|
Author: | John_Vella [ Sat Sep 11, 2010 10:06 am ] | ||||||||||||||||||
Post subject: | Re: Visual Basic 2010 question about displaying data in a form | ||||||||||||||||||
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. ![]() |
Author: | big_D [ Sat Sep 11, 2010 3:43 pm ] |
Post subject: | Re: Visual Basic 2010 question about displaying data in a form |
That is Java, not VB... The VB would be: expo1 = ndval * ssval mylabel.text = expo1 |
Author: | forquare1 [ Sat Sep 11, 2010 4:53 pm ] |
Post subject: | Re: Visual Basic 2010 question about displaying data in a form |
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 ![]() |
Author: | John_Vella [ Sat Sep 11, 2010 10:01 pm ] |
Post subject: | Re: Visual Basic 2010 question about displaying data in a form |
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... ![]() |
Author: | John_Vella [ Tue Jan 18, 2011 8:35 pm ] | |||||||||
Post subject: | Re: Visual Basic 2010 question about displaying data in a form | |||||||||
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 ![]() |
Author: | JJW009 [ Wed Jan 19, 2011 12:18 am ] | |||||||||
Post subject: | Re: Visual Basic 2010 question about displaying data in a form | |||||||||
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 ![]() |
Author: | John_Vella [ Wed Jan 19, 2011 9:11 am ] |
Post subject: | Re: Visual Basic 2010 question about displaying data in a form |
After I added the module and removed the variables from the individual forms it worked a treat, so thanks a million JJ! ![]() |
Author: | finlay666 [ Wed Jan 19, 2011 9:03 pm ] | |||||||||
Post subject: | Re: Visual Basic 2010 question about displaying data in a form | |||||||||
Easiest way is a global (if vb supports it) OR Pass it via the method that opens the form I'd say |
Author: | John_Vella [ Thu Jan 20, 2011 9:33 am ] |
Post subject: | Re: Visual Basic 2010 question about displaying data in a form |
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) |
Author: | finlay666 [ Thu Jan 20, 2011 4:30 pm ] | |||||||||
Post subject: | Re: Visual Basic 2010 question about displaying data in a form | |||||||||
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) |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |