Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Why does this happen
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
shrim




PostPosted: Mon Dec 03, 2012 5:27 pm   Post subject: Why does this happen

When i program in VB 2008 and want to get user input it makes me put CInt infront of the Val()
example:
widthA = CInt(Val(Me.txtBoxWidth.Text))
if i do not put the CInt i get a run time error and when i tell my teacher about this he said it should not be doing that because at my school computer it does not require CInt only on my computer.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Dec 03, 2012 7:30 pm   Post subject: RE:Why does this happen

likely because the input from a textbox is treated as a string (words), and you'd need to explicitly convert it to an integer (numbers) before use.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Panphobia




PostPosted: Mon Dec 03, 2012 7:51 pm   Post subject: RE:Why does this happen

But usually, at least when I used vb.net in grade 10, I never needed to convert it, you would automatically get the text from the textbox and store it in an int var
Tony




PostPosted: Mon Dec 03, 2012 9:27 pm   Post subject: Re: RE:Why does this happen

Panphobia @ Mon Dec 03, 2012 7:51 pm wrote:
...when I used vb.net in grade 10...

shrim @ Mon Dec 03, 2012 5:27 pm wrote:
When i program in VB 2008...


Sounds like you might be comparing different (versions of) languages.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: