dcsimg
Results 1 to 5 of 5

Thread: Sample Calculations

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2011
    Posts
    26

    Sample Calculations

    Hello guys,
    I'm trying to design cathodic protection for offshore pipelines using visual basics. However, I'm not very familiar with vb.
    I'm hoping I can start with basic calculations like finding pipe surface area etc.
    Does anyone know how I can design a dialog box to input pipe dimensions like length and diameter to enable me calculate the surface area?
    Any help will be much appreciated

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,695

    Re: Sample Calculations

    Add a form to your project and then add the appropriate controls to the form. That's how you design any form. You can use TextBoxes but you must then allow for the fact that the user may enter non-numeric data. You can also use NumericUpDowns, which will ensure that the user enters numbers but do have some limitations. You might also like to follow the CodeBank link in my signature and check out my Numeric Text Box thread. You're free to use that control in your own projects as you see fit.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2011
    Posts
    26

    Re: Sample Calculations

    Thanks Jmcilhinney. I'll try that out

  4. #4
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,523

    Re: Sample Calculations

    To create a dialog is fairly easy, create a new project in Visual Studio 2010 and a form named form1 will be shown, place controls on the form using the toolbox giving each input control a meaningful name. In regards to selecting controls TextBox controls are good for general input but when validation time comes everything in these controls are of type string so you will need to convert them to an numeric type such as Integer, Double, Decimal etc. When converting look at each types TryParse method to ensure the information taken from say a TextBox is actually valid for your calculations. For some user input Numeric Up/Down controls might be an alternate to a TextBox. Of course there are other controls but for basic input for calculations these are the best to begin with.

    Make sure to set Option Strict On as it makes you write better code at design time where Option Strict Off errors can be missed at design time and reveal themselves at run time. An error might be a calculation not producing the proper result to an exception raised that could have been caught at design time.

    Take your time to learn how to get around Visual Studio and the basics of VB, which will greatly assist you as you progress with your project.

    Resources

    Operators http://msdn.microsoft.com/en-us/libr...v=VS.100).aspx
    Efficient Combination of Operators http://msdn.microsoft.com/en-us/library/7txdtzy9.aspx

    Option Strict http://msdn.microsoft.com/en-us/libr...v=VS.100).aspx

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2011
    Posts
    26

    Re: Sample Calculations

    Cheers Kevin

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width