3 Replies - 296 Views - Last Post: 15 April 2019 - 06:27 AM Rate Topic: -----

#1 Alcatraz   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 14-April 19

output input data types in vb

Posted 14 April 2019 - 09:32 PM

Please help to explain the output of the following 2 statements with the input of 1 , 1.9999999.
I'm struggling with understanding the conversions. Also DOES the code require parentheses see below? Thank you!


Dim lcAnswer As Integer
lcAnswer = lcInt1 + lcDec2
lblNumberAnswerInt.Text = lcAnswer
OUTPUT: 2,2


Dim lcAnswer As Decimal = 0
lcAnswer = lcInt1 + lcDec2
lblNumberAnsDec.Text = lcAnswer

OUTPUT:
I did not get any response from the form or code for this but I think the solution is 2,2.9999999
As well I think it needs to be rewritten to
lcAnswer = lc(Int1) + lc(Dec2)
lblNumberAnsDec.Text=lcAnswer
So that this adds together -(I may be wrong!)

Is This A Good Question/Topic? 0
  • +

Replies To: output input data types in vb

#2 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6792
  • View blog
  • Posts: 28,049
  • Joined: 12-December 12

Re: output input data types in vb

Posted 15 April 2019 - 02:20 AM

I think you should provide fuller code, including all declarations. Place code between code tags when posting.

In particular, a label displays 3 for me for the first code block, and which two outputs are you referring to?
Was This Post Helpful? 0
  • +
  • -

#3 DarenR   User is offline

  • D.I.C Lover

Reputation: 602
  • View blog
  • Posts: 3,993
  • Joined: 12-January 10

Re: output input data types in vb

Posted 15 April 2019 - 06:11 AM

i dont know how your stuff is outputting-- usually placing an integer or any number in a text field breaks the code without using .tostring()
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6792
  • View blog
  • Posts: 28,049
  • Joined: 12-December 12

Re: output input data types in vb

Posted 15 April 2019 - 06:27 AM

Without Option Strict On it will not error and a number will be converted to a string for display.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1