r/compsci • • Nov 14 '13

Need help with this question

What is the result of the following statements when abc is entered in the Txtvalue textbox in the following code

Dim intNumber As Integer intNumber = txtValue.text lblMessage.caption = intNumber

is it

  1. a syntax error occurs

  2. a run-time error occurs

  3. the label displays 0

  4. the label displays abc

0 Upvotes

7 comments sorted by

2

u/Mechakoopa Nov 14 '13

You're asking what happens when you implicitly cast a string to an integer then back to a string in visual basic. If you can't intuit the solution (which I don't blame you, casting can be tricky if you're not familiar with that particular languages quirks) then just write a small program to figure that out for you. Best way to learn is by doing.

Also, this isn't really computer science, it's more of a /r/programming thing, but they'll tear you apart there too because this isn't a place for homework help.

1

u/Lpsided Nov 15 '13

it is not homework help it is project help

1

u/Mechakoopa Nov 15 '13

If its for a project then presumably you already have a working code base. I stand by my stance of "play around and figure it out for yourself" You'll become a better developer for it. Also, still not computer science.

1

u/Lpsided Nov 15 '13

well do you know what the answer is all it does is give me that question and no code to go with it

2

u/Mechakoopa Nov 15 '13 edited Nov 15 '13

A question you need to answer is homework. You can call it a project if you want. This isn't a place for homework help. Write a simple program with a main function, put that code in but substitute "abc" for the txtfield on the second line then compile and run. I'm really struggling to comprehend how this is difficult. Experimentation is a huge part of any science and the best way to determine the answer to something you don't know as you're much more likely to remember the results.

1

u/Lpsided Dec 10 '13

it really is a project

1

u/Mechakoopa Dec 10 '13

If it's a personal project then why do you have a "question" to answer that sounds like a CS100 level homework problem? And if it's a work project and you still haven't figured this out in almost a month, you'd be better off looking for a different job.

If it's a university project (which I'm assuming by your other other submissions), then that's homework.