Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7010677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:01:28+00:00 2026-05-27T22:01:28+00:00

I have a form with 3 tabs: one tab is for user entry and

  • 0

I have a form with 3 tabs: one tab is for user entry and computations, a second tab shows values that will be used for computations which are read from one database (I call it settings in that the values are constants for calculations but it’s not application settings in the way people think of it, to be clear) and the third displays a table from another database. The second tab has a table adapter interface for the dataset that contains values used for calculations that can be changed (to do different scenarios.) Those numbers are read from a single record in a database that has 20 fields and was read once when the data is loaded into the second tab to be displayed.

The problem I am having is that I would like to use the numbers from the second tab (the constants) in computations to be shown on the first tab.

I have tried declaring the variables on the second tab as public but they are already “friends” with the form event. However, when I go to use them in calculations, it’s like they don’t exist.

For example, one calculation I am doing is fuel cost. The user enters miles and this is stored as a variable called mileage. To calculate the result fuelcost, I have to use two other fields that are shown in the second tab: MPG (miles per gallon) and fuelprice (the price of gas). So fuelcost = (mileage/mpg)*fuelprice. These are read from a datatable called testdata which is actually part of the project. I want to be able to use these variables throughout the program but declaring them as public isn’t working.

How do I make the variables from one tab usable elsewhere in the program? The other thing I noticed is since the values of the variables are loaded into textboxes and assigned variable names by naming the textboxes, using val([variablename].text) isn’t solving the problem either. For example, saying milespergallon = val(mpg.text) is not doing the trick because I am getting a message that ‘text’ is not an integer when I declare milespergallon.

Update

Here the code that is being used:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim mileage = Int32.Parse(Miles.Text)
    Dim rate = 0
    Dim baserate = 0
    Dim rateper = 0
    Dim ratemile As Integer
    Dim Mpg As Decimal
    Dim milespergallon As Decimal
    milespergallon = CDec(Mpg.Text)
    ' Ensure the value is numeric 
    If IsNumeric(Mpg) Then
        Mpg = CDec(Mpg)
    Else
        milespergallon = CDbl(Mpg.Text)
    End If
    txtmilespergallon.Text = milespergallon.ToString
End Sub

TabPage2 is where the variables are displayed that I want to use in TabPage1.

Private Sub TabPage2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage2.Click

End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:01:29+00:00Added an answer on May 27, 2026 at 10:01 pm

    This is related to another post I had regarding manipulating values from a database so my answer assumes that a user has loaded data from a single row database and displayed it in a tabpage, but wants to also use that data elsewhere in the program.

    While you can drag the dataset into a tabpage to be displayed, the values from the dataset have to be stored to local variables. This has to happen in the form load event after the dataadapter fill statement in order for the numbers to be used anywhere in the form:

      Me.TestdataTableAdapter.Fill(Me.fooDataSet.testdata)
    
      variable1 = Me.fooDataSet.testdata(0).variable1
      variable2 = Me.fooDataSet.testdata(0).variable2
    

    and so on. In my example, the dataset is called ‘foo’ so it is fooDataSet. The table is called ‘testdata’ and is a single row table with several records. Think of an Excel sheet with one row and several columns…this is what testdata looks like. I’ve generically called each ‘column’ variablen where n is the number of the column for my example, although you would give them more meaningful names. Example:

      discountcost = Me.priceDataSet.pricetable(0).discountcost
      markup = Me.priceDataSet.pricetable(0).markup
    

    You can then DIM those variables. In the example of discountcost and markup, you would DIM them as decimal and then could use them in calculations in any tabpage on your form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form split apart throughout 4 tabs. One of the tabs contains
I have a number of tabs and one is a search tab. When the
I have a class that extends TabControl, basically to have one with the tabs
i have a parent form, it will have two tabs calling the two child
I have a dialog box in which there are tabs. In one of the
I need to create module in Magento which will have few database tables. One
I have WinForm which is a tab based and including all Tabs it has
I have a tabbed html form. Upon navigating from one tab to the other,
I have used a jquery UI tabs plugin in my page and in one
I have one notebook with some tabs in my form and in this tabs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.