CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2003
    Location
    Ft. Worth Texas
    Posts
    31

    [RESOLVED] .NET4.0 / VS 2010>Does Not Exsist In Current Context error

    I just don't know what to do with this. Can someone help?

    Code:
     
    using Microsoft.Win32.SafeHandles;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Data;
    using System.IO;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Text;
    using System.Threading;
    using System.Windows.Forms;
    
    namespace Test1
    {
        public partial class UserControl1 : UserControl
        {
            
            private int unitOfMeasure = 0;
            public int UnitOfMeasure
            {
                get { return unitOfMeasure; }
                set { unitOfMeasure = value; }
            }
            public int MeterTypeSelected = 0;
    
    
            public string[,] UOMText = new string[48, 48];
    
            public string TempMeterTitle = "TempTitle";
    
    
            public UserControl1()
            {
                InitializeComponent();
                //ToDo: Fill UOMText Array
            }
            
            private void timer1_Tick(object sender, EventArgs e)
            {
                lblUOM.Text = UOMText(MeterTypeSelected, UnitOfMeasure);
                lblMeterTitle.Text = TempMeterTitle.ToString();
            }
        }
    }
    The problem is with the line (Under the timer1_tick near the end of the page):
    lblUOM.Text = UOMText(MeterTypeSelected, UnitOfMeasure);

    The error is: "The name 'UOMText' does not exsist in the current context."

    What I find puzzling is the next line does not have the issue. Hmm...

    What do I need to do to fix this?

    Thanks

  2. #2
    Join Date
    May 2011
    Location
    Washington State
    Posts
    220

    Re: .NET4.0 / VS 2010>Does Not Exsist In Current Context error

    That is a strange exception to receive regarding that particular object... I would expect something like 'using a variable like a method' in your case....

    To access an array item, use brackets [ ] rather than parens ( ) .... ie:

    Code:
    string item = UOMText[1,1];
    Best of luck!

  3. #3
    Join Date
    Feb 2003
    Location
    Ft. Worth Texas
    Posts
    31

    Re: .NET4.0 / VS 2010>Does Not Exsist In Current Context error

    Thanks fcronin!

    Wow, I don't think I would ever figured that one out, brackets rather than parens!

    You solved my problem.

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

Featured