473,699 Members | 2,717 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Write to struct, Read struct into textBox2 using Microsoft Visual C++ 2008 Express Wi

1 New Member
Expand|Select|Wrap|Line Numbers
  1.  
  2. // 12 lines of code to work with windows
  3. // What I added is in red, the dark red far left 
  4. // is needed the blue is what it wrote   
  5.       #pragma once
  6.             namespace WriteRead {
  7.             using namespace System;
  8.             using namespace System::ComponentModel;
  9.             using namespace System::Collections;
  10.             using namespace System::Windows::Forms;
  11.             using namespace System::Data;
  12.             using namespace System::Drawing;
  13.    // I moved what the program wrote over to the left
  14.    // avoid more confusion
  15.    // >>>|
  16.    // <<<what I add is on the right side 
  17.    // this is where I put the struct not in the .cpp
  18.    // file
  19. public value struct Book{
  20.    // I found an example that is using struct at
  21.    // http://www.functionx.com/vccli/applications
  22.    // /carinventory.htm
  23.    // that example is using Visual C++ 2005, I am using
  24.    // Visual C++ 2008 Express Edition
  25. String ^ tx; // I will trying to do direct access
  26.    // to a text file, to load a page[].tx into textBox2
  27.    // (later)
  28.    // using String pointers? I feel no control and all
  29.    // would be lost if not saved to file
  30.    // char tx[100]; // I would like to do it this way
  31.    // do you have some idea how?
  32. }; // Will I be able to do direct access in a file
  33.    // using "String ^ tx;" ? 
  34.    // If I log the end of the file each time I add a
  35.    // structs, how does it know to only read one back?
  36.    // Using pointers?
  37.    // How does it know the end of one struct? 
  38.    // Book page[10]; // I can not used it this way and
  39.    // not needed I will need a array for index location
  40.  
  41.             /// <summary>
  42.             /// Summary for Form1
  43.             ///
  44.             /// WARNING: If you change the name of
  45.                 /// this class, you will need to change
  46.                 /// the 'Resource File Name' property 
  47.                 /// for the managed resource compiler 
  48.                 /// tool associated with all .resx 
  49.                 /// files this class depends on. 
  50.                 /// Otherwise, the designers will not 
  51.                 /// be able to interact properly with 
  52.                 /// localized resources associated with 
  53.                 /// this form.
  54.             /// </summary>
  55.             public ref class Form1 : public 
  56.                 System::Windows::Forms::Form
  57.             {
  58.             public:
  59.             Form1(void)
  60.             {
  61.                 InitializeComponent();
  62.                 //
  63.                 //TODO: Add the constructor code here
  64.                 //
  65.             }
  66.  
  67.             protected:
  68.             /// <summary>
  69.             /// Clean up any resources being used.
  70.             /// </summary>
  71.             ~Form1()
  72.             {
  73.                 if (components)
  74.                 {
  75.                 delete components;
  76.                 }
  77.             }
  78.             private: 
  79.                 System::Windows::Forms::TextBox^
  80.                 textBox1;
  81.             protected: 
  82.             private: 
  83.                 System::Windows::Forms::Button^
  84.                 button1;
  85.             private: 
  86.                 System::Windows::Forms::TextBox^
  87.                 textBox2;
  88.  
  89.             private:
  90.             /// <summary>
  91.             /// Required designer variable.
  92.             /// </summary>
  93.             System::ComponentModel::Container
  94.             ^components;
  95.             private: 
  96.                 System::Windows::Forms::Button^ 
  97.                 button2;
  98.             private: 
  99.                 System::Windows::Forms::Label^  label1;
  100. static array<Book ^> ^ page = gcnew array<Book ^>(10);     
  101.   // will need just one // how do you read this?
  102.   // I found in a book they could read this, I will
  103.   // try to post it
  104.   // If I say someting in human language like: "need 10
  105.   // Book struck" the program should ask some questions
  106.   // and refine my word and help me write human language
  107.   // or/and in c++ or c# and it would be teaching me
  108.   // and I am sure it would know about gc in "gcnew".
  109.  
  110.         #pragma region Windows Form Designer 
  111.         generated code
  112.             /// <summary>
  113.             /// Required method for Designer support -  
  114.             /// do not modify
  115.             /// the contents of this method with the 
  116.             /// code editor.
  117.             /// </summary>
  118.             void InitializeComponent(void)
  119.             {
  120.                 this->textBox1 = (gcnew 
  121.                 System::Windows::Forms::TextBox());
  122.                 this->button1 = (gcnew 
  123.                 System::Windows::Forms::Button());
  124.                 this->textBox2 = (gcnew 
  125.                 System::Windows::Forms::TextBox());
  126.                 this->button2 = (gcnew 
  127.                 System::Windows::Forms::Button());
  128.                 this->label1 = (gcnew 
  129.                 System::Windows::Forms::Label());
  130.                 this->SuspendLayout();
  131.                 // 
  132.                 // textBox1
  133.                 // 
  134.                 this->textBox1->Location = 
  135.                 System::Drawing::Point(30, 28);
  136.                 this->textBox1->Name = L"textBox1";
  137.                 this->textBox1->Size = 
  138.                 System::Drawing::Size(100, 20);
  139.                 this->textBox1->TabIndex = 0;
  140.                 // 
  141.                 // button1
  142.                 // 
  143.                 this->button1->Location = 
  144.                 System::Drawing::Point(30, 64);
  145.                 this->button1->Name = L"button1";
  146.                 this->button1->Size = 
  147.                 System::Drawing::Size(100, 25);
  148.                 this->button1->TabIndex = 1;
  149.                 this->button1->Text = L"button1";
  150.                 this->button1->UseVisualStyleBackColor
  151.                 = true;
  152.                 this->button1->Click += gcnew 
  153.                 System::EventHandler(this,
  154.                 &Form1::button1_Click);
  155.                 // 
  156.                 // textBox2
  157.                 // 
  158.                 this->textBox2->Location =
  159.                 System::Drawing::Point(30, 108);
  160.                 this->textBox2->Name = L"textBox2";
  161.                 this->textBox2->Size = 
  162.                 System::Drawing::Size(100, 20);
  163.                 this->textBox2->TabIndex = 2;
  164.                 this->textBox2->Text = 
  165.                 this->textBox1->Text;
  166.                 // 
  167.                 // button2
  168.                 // 
  169.                 this->button2->Location = 
  170.                 System::Drawing::Point(30, 146);
  171.                 this->button2->Name = L"button2";
  172.                 this->button2->Size = 
  173.                 System::Drawing::Size(100, 23);
  174.                 this->button2->TabIndex = 3;
  175.                 this->button2->Text = L"Close";
  176.                 this->button2->UseVisualStyleBackColor
  177.                 = true;
  178.                 this->button2->Click += gcnew 
  179.                 System::EventHandler(this,
  180.                 &Form1::button2_Click);
  181.                 // 
  182.                 // label1
  183.                 // 
  184.                 this->label1->AutoSize = true;
  185.                 this->label1->Location = 
  186.                 System::Drawing::Point(30, 13);
  187.                 this->label1->Name = L"label1";
  188.                 this->label1->Size = 
  189.                 System::Drawing::Size(86, 13);
  190.                 this->label1->TabIndex = 4;
  191.                 this->label1->Text = L"Type in 
  192.                 textBox1";
  193.                 // 
  194.                 // Form1
  195.                 // 
  196.                 this->AutoScaleDimensions = 
  197.                 System::Drawing::SizeF(6, 13);
  198.                 this->AutoScaleMode = 
  199.             System::Windows::Forms::AutoScaleMode::Font;
  200.                 this->ClientSize = 
  201.                 System::Drawing::Size(166, 194);
  202.                 this->Controls->Add(this->label1);
  203.                 this->Controls->Add(this->button2);
  204.                 this->Controls->Add(this->textBox2);
  205.                 this->Controls->Add(this->button1);
  206.                  this->Controls->Add(this->textBox1);
  207.                 this->Name = L"Form1";
  208.                 this->Text = L"Form1";
  209.                 this->Load += gcnew 
  210.                 System::EventHandler(this,
  211.                 &Form1::Form1_Load);
  212.                 this->ResumeLayout(false);
  213.                 this->PerformLayout();
  214.             }
  215.         #pragma endregion
  216.                   private: System::Void 
  217.                   Form1_Load(System::Object^  sender,
  218.                   System::EventArgs^  e) 
  219.                   {  
  220.    // This is not the way I want to write to the array 
  221.    // of structs for a 1000 pages of text 
  222. page[0] = gcnew Book; // all this is to test some ideas
  223. page[1] = gcnew Book; // later will write to just one  
  224.    // struct not 4
  225. page[2] = gcnew Book; // then save it to file and log 
  226.    // location in index array
  227. page[3] = gcnew Book; // then retrive from text file  
  228.    // with direct random access
  229.                   }                          
  230.               private: System::Void 
  231.                   button1_Click(System::Object^ 
  232.                   sender, System::EventArgs^  e) 
  233.                   {
  234. this->page[3]->tx = this->textBox1->Text; // copy 
  235.   // textBox1 to struct[3] this works good
  236.   // this->textBox2->Text = this->textBox1->Text;  
  237.   // copy box1 to box2, this works good use to help 
  238.   // test 
  239. this->textBox1->Text = " "; // clear textBox1 this 
  240.   // works good
  241. this->textBox2->Text = this->page[3]->tx; // From 
  242.   // struct to textBox2 ok it is working good
  243.                  }
  244.                  private: System::Void 
  245.                  button2_Click(System::Object^  sender, 
  246.                  System::EventArgs^  e) 
  247.                  {
  248.   // Close();//or you could say
  249. Application::Exit();
  250.                  }
  251.          };
  252. }
  253.  
Sep 10 '16 #1
0 1043

Sign in to post your reply or Sign up for a free account.

Similar topics

1
8846
by: Jón Sveinsson | last post by:
Hello everone I have code from c which I need to convert to c#, the c code is following, as you can see there is a struct inside struct typedef struct { some variables....
3
1872
by: clintonG | last post by:
Visual C# 2005 Express Edition is a simple, lightweight, integrated development environment designed for beginning programmers and non-professional developers interested in building Windows Forms, class libraries, and console-based applications. Visual C# 2005 Express Edition includes many of the same productivity features found in Visual Studio, all streamlined to fit the needs of the non-professional Windows developer. -- <%=...
2
3689
by: Tiger | last post by:
I try to write a struct into a brut file but I can't write all var in this struct when I try to add user I have that : > testmachine:/usr/share/my_passwd# ./my_passwd -a users.db > Ajout d'une entrée dans la base : > > Username : test > Password : aze > Gecos : qsd
2
1360
by: Schizoid Man | last post by:
Hi, I want to write some custom UDFs for Excel in C# and and build them into XLLs. However, I can't seem to check the Register for Com Interop box in the Express Edition of VC#. Is this a known limitation of VC# Express? Is there a way for me to still use the Express edition to build my functions?
4
3345
by: talkingpidgin | last post by:
I am trying to compile my first windows program using microsoft visuall c++ express. It is a command line program that must run completely isolated without any setup. It's not a large or complicated program at all and I can't imagine why it would be so difficult to deploy such a simple exe. However, when I try to deploy the program (on non-build machines) it complains that it is installed or configured incorrectly. I figured out it's...
3
2911
by: HelloWorldHelloWorldHello | last post by:
How to send email to another person with using Microsoft Visual Basic 6.0.?
5
4332
by: XiCookieX | last post by:
I'm not sure if I am in the right section. If i am not I'm very sorry, but can you guys at least answer my question: I tried downloading the Microsoft Visual C++ 2008 Express Edition Trial and everytime when its finished and done it says in the end: Setup could not install the following component: Microsoft Visual C++ 2008 Express Edition -ENU I have tried everything, i redownloaded it like 20 times already and deleted the...
4
2619
by: Colin J. Williams | last post by:
1.I have both 2.5 and 2.6 but both appear, under Recent Projects, as pcbuild. It would be helpful if the Python Version could be indicated. 2.With 2.6, Python compiles and executes OK but various packages are not compiled, eg sqlite3. 3.Pythonw compiles OK but not sqlite3. 4.Mike Fletcher suggests an approach (http://www.vrplumber.com/programming/mstoolkit/)
3
1070
by: Andrus | last post by:
I have C# 2008 Express. I installed Microsoft Source Aanalysis but havent found any executatable or menu in C# express. How to use it without visual Studio ? Andrus.
1
1758
by: tvnaidu | last post by:
After load new project, I can build, at the bottom I can see build log, on right side I can see project name (Bold), on center window it shows "visual studio news", on left side it shows "Recent projects", "Getting started", how can I load source file, also I cannot see "Toolbox" on main window, any idea?
0
8623
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9054
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8896
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5879
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3071
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2362
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.