IDE

Visual Studio એ workshop છે: screen ને draw કરવા form designer, controls drag કરવા Toolbox, configure કરવા Properties window, અને double-click જે તમને event ના code માં drop કરે છે.

10 min read · 10 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

program જે તમે draw કરી શકો છો

તમારા BCA નો અત્યાર સુધીનો દરેક program, C થી Java સુધી, same રીતે born થયો હતો: blank text file.

આજે different છે. તમે ShopKeeper ની first window ને drawing દ્વારા બનાવશો: button ને palette થી drag કરો, window પર drop કરો, mouse સાથે resize કરો. code હજુ exists કરે છે, પણ screen ના layout માટે તમે typist નહીં, designer જેવું work કરો છો.

આને possible બનાવતું workshop એ Visual Studio IDE છે, અને તેના 4 main panels ને જાણવું IS આ lesson છે.

Theory

4 panels, ઔપચારિક રીતે

IDE (Integrated Development Environment) એ editor, designer, compiler અને debugger ને એક tool માં bundle કરે છે. Visual Studio ના Windows-Forms workspace માં 4 panels છે જે exam માં name કરવાના છે:

  • Form designer: canvas; તમારું window જેવું look થશે તેવું
  • Toolbox: controls ની palette (Button, TextBox, Label...) જે તમે form પર drag કરો છો
  • Properties window: selected control નું દરેક setting: તેનું Name, Text, size, colour; plus તેના events ની list
  • Solution Explorer: project ની files

Follow along

ShopKeeper ની first window, click by click

  1. File, New, Project: Windows Forms App (Visual Basic) તેને ShopKeeper name આપો. Visual Studio designer માં Form1 ને open કરે છે.
  2. Toolbox થી Button ને form પર drag કરો તે Button1 તરીકે lands થાય છે. shop ના name માટે Label ને પણ drag કરો.
  3. Properties window માં properties set કરો button ને select કરો: Name = btnWelcome, Text = Welcome. code પહેલાં meaningful names: btnTotal, txtItem, lblBill.
  4. button પર double-click કરો Visual Studio code view પર jumps કરે છે અને તમારા માટે btnWelcome_Click event handler ને generate કરે છે.
  5. તેની અંદર એક line લખો, પછી F5 દબાવો MsgBox("Welcome to Mehta Stores"). F5 build અને run કરે છે; button પર click કરો અને box appear થાય છે.

Practical

શું double-click એ generate કર્યું (plus તમારી line)

Public Class Form1

    Private Sub btnWelcome_Click(sender As Object, e As EventArgs) _
            Handles btnWelcome.Click
        MsgBox("Welcome to Mehta Stores")
    End Sub

End Class

Theory

એક form ના બે views

સમજો કે double-click એ શું reveal કર્યું: તમારું form 2 views માં lives કરે છે.

designer view SHOW કરે છે કે window કેવું look થાય છે. code view SHOW કરે છે કે તે કેવું behave કરે છે. તેઓ same Form1 ને describe કરે છે; form પર right-click કરો અને View Code / View Designer તેમની વચ્ચે switches કરે છે.

generated method ની tail matters કરે છે: Handles btnWelcome.Click એ VB.NET ની wiring છે, declaring કે આ Sub run થાય છે જ્યારે પણ તે button click થાય છે. આ event-driven style (code user ની wait કરે છે) એ desktop પર BCA305-02 નું Android pattern છે.

Quiz

તમે ShopKeeper નું button select કર્યું છે અને તેનું caption Button1 ને બદલે Total કહેવું જોઈએ છે. તે change ક્યાં happen થાય છે?

  1. Text property, Properties window માં
  2. Name property, Properties window માં
  3. Toolbox entry ને Button માટે edit કરો
  4. તે ફક્ત code માં, run time પર change કરી શકાય છે
Show the answer

Text property, Properties window માં

Text એ છે જે user control પર reads કરે છે; તેને Properties window માં change કરવાથી designer instantly update થાય છે. Name (option B) એ identifier છે જે code use કરે છે, btnTotal, user માટે invisible: Text/Name split એ exam નો favourite IDE question છે. Toolbox (option C) એ control TYPES ની palette છે; તેને edit કરવાથી તમારા form પર કંઈ change થતું નથી. Option D best પર half-true છે: run-time changes possible છે (btnTotal.Text = "Total"), પણ design time exactly એ છે જે Properties window માટે છે.

Think first

misfire ને predict કરો

classmate button ને બદલે FORM ના empty area પર double-click કરે છે, અને જે કંઈ open થયું તેમાં MsgBox line ને types કરે છે. program runs કરે છે, પણ box click પર ક્યારેય appear થતું નથી. શું થયું, અને ક્યારે box appear થશે?

Show the answer

control પર double-click કરવાથી તેના DEFAULT event નો handler generate થાય છે, અને form નું default event Load છે, Click નહીં. MsgBox line Form1_Load માં landed થઈ ગઈ, જે એકવાર run થાય છે, જ્યારે window open થાય છે: એટલે box startup પર appear થાય છે અને button પર ક્યારેય નહીં. fix: ત્યાં તેને delete કરો, BUTTON પર double-click કરો, અને line ને btnWelcome_Click માં મૂકો. rule worth keeping: always generated Sub નું name અને Handles clause ને type કરતા પહેલાં read કરો.

Watch out

Habits જે future marks (અને hair) ને save કરે છે

controls ને immediately name કરો: 12 controls ને Button1..Button12 તરીકે leave કરો અને next week નું code unreadable છે. btnTotal, txtQty, lblAmount, dgvBill: prefix + meaning.

designer-generated region ને by hand edit ન કરો: layout code જે Visual Studio એ designer માટે લખ્યું છે તે hand-mangled થાય તો break થાય છે; form ને designer અને Properties window દ્વારા change કરો.

F5 vs Build: F5 = build AND run debugger સાથે; red-underlined error list એટલે તે ક્યારેય actually run નથી થયું.

Theory

room ready છે

તમે હવે workshop ને જાણો છો: canvas, palette, settings panel, file tree, અને form ના 2 views. Unit 3 જે કંઈ કરે છે એ આ loop repeated છે: control ને drag કરો, name કરો, properties set કરો, તેના events ને handle કરો. પણ અહીં અને ત્યાં વચ્ચે, ShopKeeper ને તેના brain ની જરૂર છે: variables, calculations અને decisions VB.NET itself માં. એ Unit 2 નો rest છે, data types અને Dim statement થી starting.

Summary

Key takeaways

  • IDE = editor + designer + compiler + debugger એક માં; Visual Studio એ .NET નું છે.
  • Four panels: form designer (canvas), Toolbox (control palette), Properties window (settings + events), Solution Explorer (files).
  • Flow: new Windows Forms project, controls drag કરો, Name અને Text set કરો, double-click, code, F5.
  • Text એ છે જે users see કરે છે; Name એ છે જે code use કરે છે: meaningful names પહેલાં set કરો.
  • Double-click control ના DEFAULT event handler ને generate કરે છે; form નું Load છે, button નું Click છે.
  • Handles Sub ને event સાથે wire કરે છે: BCA305-02 ના Android listeners નો desktop cousin.
  • Memory hook: screen ને draw કરો, parts ને name કરો, behaviour માં double-click કરો.

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Programming in Visual Basic .NET

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

IDE · .NET Programming · Gri-Learn