2 Replies - 626 Views - Last Post: 27 May 2013 - 06:55 AM Rate Topic: -----

#1 zaki khan  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 22-May 13

Declaration expected problem

Posted 27 May 2013 - 12:37 AM

Peace be with all of you.
i am facing a very irritatin error. i have decleared every variable first globaly and then locally to get rid of that error but invain.
    Dim goldrate_tab2 As Double
    Dim goldmazdori_tab2 As Double
  

'assigning values to variables from textboxes
     goldrate_tab2 = Val(txtbox_goldrate_tab2.Text)
        goldmazdori_tab2 = Val(txtbox_totalgoldprice_tab2.Text)


Is This A Good Question/Topic? 0
  • +

Replies To: Declaration expected problem

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,991
  • Joined: 08-June 10

Re: Declaration expected problem

Posted 27 May 2013 - 01:08 AM

Could you show us the exact error message you are getting? Error messages include a lot of info, much of which could be helpful here. - And perhaps more of the code surrounding the error. There doesn't look like there is any error in the four lines you posted already. The problem may lie somewhere in the surrounding code.


One other thing, though. I'm not much of a VB.NET coder myself, but isn't the Val function a more or less obsolete VB6 compatibility thing? I'd have thought Doble.Parse and Double.TryParse (or their equivalents for the other numeric types, of you are using those) would be the methods to use for this purpose in .NET code.
Was This Post Helpful? 1
  • +
  • -

#3 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: Declaration expected problem

Posted 27 May 2013 - 06:55 AM

View Postzaki khan, on 27 May 2013 - 01:37 AM, said:

Peace be with all of you.
i am facing a very irritatin error. i have decleared every variable first globaly and then locally to get rid of that error but invain.
    Dim goldrate_tab2 As Double
    Dim goldmazdori_tab2 As Double
  
'assigning values to variables from textboxes
     goldrate_tab2 = Val(txtbox_goldrate_tab2.Text)
        goldmazdori_tab2 = Val(txtbox_totalgoldprice_tab2.Text)


1. If you haven't done so already, turn Option Strict On. See the link in my signature to see why.

You might want to review the MSDN article, Scope in Visual Basic, in case you have a situation where a variable is being hidden within a code block.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1