home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Applications and Operating Systems
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Topic: Hi all. Sorry my 1st post is a couple of VB questions. I hope its OK. I need a box (textbox1) that I put a number in say 100 then when I click button1 the number is decreased, but textbox1 still shows the original number...
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2234
Discussions: 186,223, Posts: 2,222,758, Members: 229,783
Old October 10th, 2008, 07:51 PM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 2
NOOB VB.Net questions

Hi all. Sorry my 1st post is a couple of VB questions. I hope its OK.

I need a box (textbox1) that I put a number in say 100 then when I click button1 the number is decreased, but textbox1 still shows the original number. Then a progressbar (progressbar1) needs to go up by the % of diff between textbox1 and the number of clicks. I.e. say TB1 is 100 and I click it 3 times it still show 100 in TB1 but the progress bar has gone up by 3%.

I can’t seem to work out where to put the number in textbox1 so that it stays the same number (100) on screen but lets me take the value i entered in it and reduce it each time I click the button.

My other question is how do I make a carridge retun in a textbox. I know its a key event but cant seem to get it to work.

TIA

Terry

tezzal is offline   Reply With Quote
Old October 10th, 2008, 09:00 PM     #2 (permalink)
Ultimate Member
 
Join Date: Oct 2001
Posts: 20,211
the spam should go away soon

Welcome to TechIMO

There are two ways to hold the number you need!
1. Cleanest and suggested method - Use a variable, for your purpose an Integer variable will work fine
2. Use a second textbox but HIDE it in the properties
When you click the decrement button, if there is currently no value in iVar1 (the integer variable) then assign it the value of textbox1. Then decrement. If there is already a value then just decrement the existing value.. the progress bar can use this value

BUT what you'll have to figure out (I'm assuming this is for class) is how do you make a variable hold its value when you leave the scope of the function.

vass0922 is online now   Reply With Quote
Old October 11th, 2008, 12:07 AM     #3 (permalink)
Member
 
Russian Wall's Avatar
 
Join Date: Aug 2004
Location: Calgary, AB,CAN
Posts: 412
Welcome to TechIMO!

Both what vass suggested would work. It is not smart to read a value directly out of a normal textbox that is not read-only, so you need to use a variable or a non-user text box like Vass suggested.

Assuming your text box is already set up, it might look something like this:
In psuedocode (this won't run, it is just to get the idea, and you have to interpret it to VB):

class clicksProgress{
int clicks;
int boxNumber;

void textboxUpdateEvent(){
boxNumber = system::convert::toInt16(textbox->text);
//If this is not a number, you will need to catch errors here too
updateProgressBar();
}

void clickEvent(){
clicks++;
updateProgressBar();
}

void updateProgressBar(){
//I don't know any of the functions for progress bar, sorry just set it here...
progressbarStatus = clicks/boxNumber;
}
Hope that helps!


What are you trying to do with the carriage return? Let somebody type it in, or display something with a CR in it? You can just put it in the textbox by using something like
textbox->text = System::String("The n is a windows endline CR + LF \n");
If you are trying to capture it, it might help to know carriage return is ascii number 13.
__________________
"By design, mathematics is useless"
-David E. Brown Mathematics PhD
/\My favourite line in learning discreet math /\

Russian Wall is offline   Reply With Quote
Old October 11th, 2008, 12:14 AM     #4 (permalink)
Ultimate Member
 
Join Date: Oct 2001
Posts: 20,211
make sure to set the textbox as multiline too
vass0922 is online now   Reply With Quote
Old October 11th, 2008, 02:43 AM     #5 (permalink)
Junior Member
 
Join Date: Oct 2008
Posts: 2
Thanks guys I'll try those and get back to you.

The CR one is a barcode scanner. I set focus to a text box then when I scan a code the CR is sent by the scanner and does a load more stuff like populate a database read values from a database etc. I have it working no problems in PHP as a web solution but need a simple VB app as well.
Thanks again.
tezzal is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Noob Mobo Questions Cowtipper2 Motherboards 6 December 3rd, 2006 01:11 PM
Accoona Search Assistant,New dot Net Questions ComputerGeek80 Applications and Operating Systems 2 April 24th, 2006 01:39 PM
Net Questions a1cnissen Networking and Internet 3 October 24th, 2004 05:43 PM
noob VB.NET MsgBox question... firewolf Applications and Operating Systems 3 September 29th, 2003 03:36 PM
Linux Questions from a noob shawshank62 Applications and Operating Systems 15 April 21st, 2003 10:04 PM

Most Active Discussions
Is It Just Me? (16966)
hi (6)
So GLAD winter's finally here !! (21)
FolderChat: Weekend time again! (284)
Folderchat Weekday thread (373)
Super folding (18)
Popular Online Pc Retailers (12)
AM2+/AM3 (9)
PSU recommendation, think mines is .. (14)
Recent Discussions
Super folding (18)
RETTEN.EXE missing (1)
HDMI Cables (6)
Is it worth the upgrade? (2)
Need advice from you experts... (2)
Help me to find Equivalent Powe.. (156)
Calculating KVA/MAX (7)
Why do you use "Vista".. (29)
Sapphire Radeon HD 3850 512Mb A.. (1)
Seald copy of windows 95 for sa.. (0)
Various items for sale (1)
Woot-off (5)


All times are GMT -4. The time now is 11:43 AM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28