Results 1 to 5 of 5

Thread: [RESOLVED] Error on creating user control object

  1. #1

    Thread Starter
    Lively Member pourkascheff's Avatar
    Join Date
    Apr 2020
    Location
    Earth
    Posts
    64

    Resolved [RESOLVED] Error on creating user control object

    Hi all,
    This error occurs whenever I place my user control on vb.net form.
    Name:  error.png
Views: 142
Size:  50.3 KB

    How can I rectify it?
    𝕬𝖒𝖎𝖗 𝕽. 𝕻𝖔𝖚𝖗𝖐𝖆𝖘𝖈𝖍𝖊𝖋𝖋

  2. #2
    Fanatic Member
    Join Date
    Aug 2004
    Location
    Essex, UK
    Posts
    682

    Re: Error on creating user control object

    The error message tells you exactly what the problem is. You can't convert "NaN%" to a double because it is Not A Number. You need to show us your code if you want us to help you work out why your string is "NaN%" when you expected it to be something like "123456".

    EDIT: It might just be a case of using TryParse and assigning 0 to your double if it fails.
    Last edited by paulg4ije; May 15th, 2021 at 03:49 AM.

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,639

    Re: Error on creating user control object

    Quote Originally Posted by pourkascheff View Post
    How can I rectify it?
    You're obviously doing some bad maths to get that text in the first place. I suspect that you are doing a percentage calculation somewhere and converting the result to a String but the result is Double.NaN. You're probably dividing by zero but a proper debug will tell you for sure.

    You shouldn't need us to tell you to do a proper debug in the first place. The exception info you posted tells you exactly what the issue is and where it occurred. Did you even read it before posting? You should have immediately placed a breakpoint on that line 127 and seen for yourself what the issue was. You could have then worked backwards to see where the bad data was coming from and what you could do to prevent. That's all stuff you should be doing before posting here, then only posting if you can't work it out.

  4. #4

    Thread Starter
    Lively Member pourkascheff's Avatar
    Join Date
    Apr 2020
    Location
    Earth
    Posts
    64

    Re: Error on creating user control object

    Quote Originally Posted by jmcilhinney View Post
    I suspect that you are doing a percentage calculation somewhere
    You could be a super detective jmcilhinney =))) I'm serious.

    Quote Originally Posted by paulg4ije View Post
    It might just be a case of using TryParse and assigning 0 to your double if it fails.
    Exactly, But I'll tell you what I did.

    Visual Studio has already ruined my projects close to the end, many times.
    So, I used to back them up every few steps. I restored my RAR file and started to code again and tbh a better way was figured out and applied. No more errors has been took place @ the moment now.
    𝕬𝖒𝖎𝖗 𝕽. 𝕻𝖔𝖚𝖗𝖐𝖆𝖘𝖈𝖍𝖊𝖋𝖋

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    107,639

    Re: Error on creating user control object

    Quote Originally Posted by pourkascheff View Post
    Visual Studio has already ruined my projects close to the end, many times.
    You should be using source control to begin with. You can get a free Azure DevOps account and support is built right into VS. It also supports GitHub, any other Git provider and many other source control providers too. You can then revert to any previous state with a few clicks right in VS.

    That said, if you keep having projects corrupted then either it's actually your fault or there's something wrong with your VS installation and you should be doing a repair or possibly even a full reinstall. I've never had such issues - the odd thing here and there but never anything consistent - and I've been using VS since 2003. It's not normal so don't just accept it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width