Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 10th, 2008, 12:00 PM
Registered User
 
Join Date: Sep 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to etow Send a message via MSN to etow Send a message via Yahoo to etow
Default Need Help With System String^ variable

Hi,

How do you make a System String^ variable called results, for example, declared in the namespace class of Form1 of the Windows Form Application, to be made globally accessible to a .H Header file that contains unmanaged code? I need to access a textbox text field of the main namespace class Form1 of Windows Form Application from a .H Header file in order to print out the text results from the System String^ variable called results to a textbox in the namespace class of main Form1 in the Windows Form Application. I know how to output the System String^ to a textbox from the Form1 but not sure how to get .H form to do it?

I was wondering how can you do this?



Please help.



Thanks

etow

 
Old October 13th, 2008, 08:45 PM
Registered User
 
Join Date: Sep 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to etow Send a message via MSN to etow Send a message via Yahoo to etow
Default

In your GlobalVariables.h file:

Code:
#include "stdafx.h"

#ifndef GLOBALVARIABLES_H
#define GLOBALVARIABLES_H

public ref class GlobalVariables
{
  public:
    static System::String^ display; 
};

#endif
-----------------------------------
Code:
In your stdafx.h file:

#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "GlobalVariables.h"
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
-----------------------------------------------

To use the global string in your code by referencing like this:

GlobalVariables:: display = GlobalVariables:: display + "a string";

or:

GlobalVariables:: display += "a string";





Similar Threads
Thread Thread Starter Forum Replies Last Post
@[System::UserName] variable in SSIS jucasti SQL Language 0 April 15th, 2008 09:44 AM
Convert a string into a variable jtrifts VBScript 4 February 21st, 2008 09:08 AM
Using System Variable in Data Flow Task samylahur BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 1 March 8th, 2006 11:37 AM
C# String to Variable? MAtkins General .NET 4 October 2nd, 2005 04:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.