1. Fayllar bilan ishlash. Fayllarni yuklash va saqlash. Fayllar bilan ishlash. Misol Matn taxrirlovchi dastur tuzing
Misol-2. Fayllar bilan ishlash. Ruyxat ListBox, ComboBox
Download 421.22 Kb. Pdf ko'rish
|
2-amaliy mashg\'ulot
Misol-2. Fayllar bilan ishlash. Ruyxat ListBox, ComboBox.
Borland C++ Builder 6 dasturini ishga tushiring va yangi papka yaratib yangi proyektni ruyxat nomi bilan yarating. Formaga ListBox, ComboBox va Memo komponentlarini o‘rnating. ListBox va ComboBox ning Items xususiyatiga xafta kunlarini kiriting. Proyekt papkasida yangi matn fayl dars.txt nomi bilan yarating va kuyidagi tartibda dars jadvalingizni kiriting: [1] 1-fan nomi; 2- fan nomi; 3- fan nomi; 4- fan nomi; [2] 1-fan nomi; 2- fan nomi; 3- fan nomi; 4- fan nomi; [3] 1-fan nomi; 2- fan nomi; 3- fan nomi; 4- fan nomi; [4] 1-fan nomi; 2- fan nomi; 3- fan nomi; 4- fan nomi; [5] 1-fan nomi; 2- fan nomi; 3- fan nomi; 4- fan nomi; [6] 1-fan nomi; 2- fan nomi; 3- fan nomi; 4- fan nomi; void __fastcall TForm1::ListBox1Click(TObject *Sender) { TStringList *sl =new TStringList; sl->LoadFromFile("dars.txt"); bool b; String s; Memo1->Lines->Clear(); for(int i =0; i < sl->Count; i++) { s = sl->Strings[i]; if(s.SubString(1,1)=="[") { b =false; if(StrToInt(s.SubString(2,s.Length()-2))== ListBox1->ItemIndex+1) { b =true; continue; } } if(b) Memo1->Lines->Add(sl->Strings[i]); } delete sl; } //--------------------------------------------------------------------------- void __fastcall TForm1::ComboBox1Change(TObject *Sender) { TStringList *sl =new TStringList; sl->LoadFromFile("dars.txt"); bool b; String s; Memo1->Lines->Clear(); for(int i =0; i < sl->Count; i++) { s = sl->Strings[i]; if(s.SubString(1,1)=="[") { b =false; if(StrToInt(s.SubString(2,s.Length()-2))== ComboBox1->ItemIndex+1) { b =true; continue; } } if(b) Memo1->Lines->Add(sl->Strings[i]); } delete sl; } Download 421.22 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling