1. Përshëndetje dhe mirësevini në forumin e Itshqip.com
    Nëse akoma nuk jeni pjesë e IT komunitetit më të madhë Shqiptarë nga fusha e Teknologjisë Informative, ju ftojmë që të bëheni pjesë e këtij komuniteti që tani duke u regjistruar këtu - procedura është shumë e thjeshtë dhe e lehtë. Gjithashtu ju mund të regjistroheni edhe përmes rrjetit social Facebook, Twitter, Google+.

Ndihm rreth nje Programi te vogel ne C#

Tema tek 'C# // C++ // VisualBasic' e hapur nga usem2, 6 Prill 2019.

  1. usem2

    usem2 Anëtar

    Postimet:
    5
    Pëlqimet:
    0
    Pikë nga trofetë:
    1
    Mirdita,

    shpresoj se jeni duke kalu nje pasdite te mir te vikendit.

    Duke kerkuar ne google pash nje program te vogel i cili shikon se a jan ip (web faqet) online apo offline.
    Linku i Programit.
    [​IMG]

    Kodi:
    namespace WebsitePingTest
    {
    using System;
    using System.Data;
    using System.Drawing;
    using System.Net.NetworkInformation;
    using System.Windows.Forms;

    publicpartialclassForm1:Form
    {
    publicForm1()
    {
    this.InitializeComponent();
    }

    privatevoidForm1_Load(object sender,EventArgs e)
    {
    var dt =newDataTable();
    dt.Columns.Add(newDataColumn("Websitename",typeof(string)));
    dt.Columns.Add(newDataColumn("URL",typeof(string)));
    dt.Columns.Add(newDataColumn("Status",typeof(string)));

    var row = dt.NewRow();
    row["Websitename"]="Google";
    row["URL"]="www.google.com";
    dt.Rows.Add(row);

    row = dt.NewRow();
    row["Websitename"]="Yahoo";
    row["URL"]="www.yahoo.com";
    dt.Rows.Add(row);

    row = dt.NewRow();
    row["Websitename"]="xasfjhasfkjh";
    row["URL"]="www.xasfjhasfkjh.com";
    dt.Rows.Add(row);

    var view =newDataView(dt);
    this.dataGridView1.DataSource= view;

    foreach(DataGridViewRow dataGridViewRow in dataGridView1.Rows)
    {
    var url = dataGridViewRow.Cells[1].Value.ToString();

    var ping =newPing();

    PingReply result =null;
    IPStatus status;
    try
    {
    result = ping.Send(url);
    status = result.Status;
    }
    catch(Exception ex)
    {
    status =IPStatus.DestinationHostUnreachable;
    }

    if(status !=IPStatus.DestinationHostUnreachable)
    {
    dataGridViewRow.Cells[2].Style.BackColor=Color.Green;
    }
    else
    {
    dataGridViewRow.Cells[2].Style.BackColor=Color.Red;
    }
    }
    }
    }
    }


    Gjat Perpilimit te programit nuk tregon as nje gabim, por kur e boj debug athere shfaqet ky problem:
    [​IMG]
    Shpresoj se dikush mund ta korigjon.
    Falemiderit.
     
  2. sodovina-city

    sodovina-city Anëtar i Njohur

    Postimet:
    712
    Pëlqimet:
    183
    Pikë nga trofetë:
    88
    Pershendetje,

    Gabimi te shfaqet per arsye qe mund te shfaqen vlera null ne ate pjese te kodit, mundesh me kontrollu vleren nese eshte null apo me vendos ne try and catch. Psh:
    Rreshtin
    Code:
    var  url = dataGridViewRow.Cells[1].Value.ToString();
    Nderroje me kodin:
    Code:
    var url = "";
    try{
        url = dataGridViewRow.Cells[1].Value.ToString();         
    }
    catch(Exception e) {
        Console.WriteLine("Vlera null");
    }
     
    Papillon dhe usem2 pëlqejnë postimin.
  3. usem2

    usem2 Anëtar

    Postimet:
    5
    Pëlqimet:
    0
    Pikë nga trofetë:
    1
    @sondovina-city Pershendetje vlla,

    problemi u rregullu, faleminderit shum edhe pse ma heret me try edhe catch e pata provu po kisha pas gabime sintaksore te pershendes dhe te uroj nje vikend te mir.

    Code:
      if (view != null)
                foreach (DataGridViewRow dataGridViewRow in dataGridView1.Rows)
                {
                    var url = " ";
                    try
                    {
                        url = dataGridViewRow.Cells[1].Value.ToString();
                    }
    
                    catch (Exception ex)
                    {
                        //MessageBox.Show("Gabim!");
                    }
     

Shpërndaje faqen

Loading...