473,323 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

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

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 1025

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

Similar topics

1
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
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,...
2
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...
2
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...
4
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...
3
by: HelloWorldHelloWorldHello | last post by:
How to send email to another person with using Microsoft Visual Basic 6.0.?
5
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...
4
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...
3
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
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.