The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > Visual Basic


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 10-20-2007, 08:45 PM
mikan mikan is offline
Novice
Join Date: Oct 2007
Posts: 3
iTrader: (0)
mikan is on a distinguished road
VB 2005 Hi all! Short little question on passing variable to textbox

//////edit: oct 22 solved. was making it lots harder than needed;
easier to call the textbox in each case. [returns are weeeeird]
don't know if that's a good explanation, but variables
pass through correctly and the whole program works now. thanks all ^______________^////

Hello I'm trying to write a program where the user enters a number in a message box, and values are calculated
through a function.
What I can't figure out is how to pass that calculated number [suppose it's a variable called quantity] to
a text box.
I do something like
quantity = (txtShipment.Text)

and get Message="Conversion from string "" to type 'Double' is not valid."

quantity is declared as a double, but I can't seem to figure this out. :/


Is there a way to go about this? Thank you muchly

edit::
after some editing, I now get a 0 in the textbox.
How can the variable pass through the function and display in a textbox?
It's going byref in the input data sub, and is byref in the function where the calculations are done.
Thanks in advance ^^;

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!

Last edited by mikan : 10-22-2007 at 11:05 PM. Reason: solved :D
Reply With Quote
  #2 (permalink)  
Old 10-21-2007, 03:50 AM
Lee's Avatar
Lee Lee is offline
PT Staff*
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: Blackpool, UK
Posts: 615
iTrader: (0)
Lee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enoughLee will become famous soon enough
If you showed your code it would make your question much clearer, from what you have said i would say try:
txtShipment.text = quantity

If thats not right then your question is not what i thought, as i said please post code.
Reply With Quote
The Following User Says Thank You to Lee For This Useful Post:
HelloWorld (10-21-2007)
  #3 (permalink)  
Old 10-21-2007, 10:46 AM
mikan mikan is offline
Novice
Join Date: Oct 2007
Posts: 3
iTrader: (0)
mikan is on a distinguished road
Edit oct 22: !! Oh right, will fix the variable name and return from the function. Hmm..
Will update post with future problem once that's figured out.
~~~~
Ok, thanks. What I aim to do is take the variable of the input box and pass it down a procedure.
Somehow the value isn't being processed through to the calculation.

These are some pieces:
Quote:
Public Class Form1

Private Sub btnCalTax_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalTax.Click
Dim income As Double

GetData(income)
FedIncomeTax(income)
txtTaxable.Text = income
End Sub
Quote:
Sub GetData(ByVal income As Double)
income = CDbl(InputBox("Enter income"))
End Sub
Quote:
Function FedTax(ByRef income As Double) As Double
Select Case income
Case 7150 To 29050
Return 0.15 * (taxableIncome - 7150)

Case 29050 To 70350
Return 0.25 * (taxableIncome - 29050)
End Select

End Function

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!

Last edited by mikan : 10-22-2007 at 04:08 PM. Reason: ~~partial solve
Reply With Quote
The Following User Says Thank You to mikan For This Useful Post:
HelloWorld (10-21-2007)
  #4 (permalink)  
Old 10-22-2007, 11:04 PM
mikan mikan is offline
Novice
Join Date: Oct 2007
Posts: 3
iTrader: (0)
mikan is on a distinguished road
whew, solved. seems to be so far, anyway :^_^:
prob not the best solution, but figured to just call the textbox up in each case instead.
don't know how to explain it, though, esp if this isn't the best answer.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #5 (permalink)  
Old 10-22-2007, 11:33 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Sorry that I couldn't help you at all because I'm not VB experienced programmer haha... ^^ but it's good that you can solve it, it happened to me before too haha...

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not 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 On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 05:57 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50