1. Este site usa cookies. Ao continuar a usar este site está a concordar com o nosso uso de cookies. Saber Mais.

Duvida C#

Discussão em 'Programação' iniciada por ricamerica, 7 de Dezembro de 2008. (Respostas: 1; Visualizações: 802)

  1. caros colegas apos seguir o vosso concelho passei a usar o metodo split para o programa que ordena o nome segundo a ordem das paginas amarelas
    exemplo

    ricardo jorge saraiva gonçalves
    fica
    gonçalves, ricardo,j.s.

    descobri alguns erros que nao consigo corrigir se me pudessem ajudar agradecia


    o codigo do form é este:

    Código:
    [SIZE=2][COLOR=#000000]namespace WindowsFormsApplication1[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]{[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]    partialclassForm1[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]    {[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        ///<summary>[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        /// Required designer variable.[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        ///</summary>[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        private System.ComponentModel.IContainer components = null;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        ///<summary>[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        /// Clean up any resources being used.[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        ///</summary>[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        ///<param name="disposing">true if managed resources should be disposed; otherwise, false.</param>[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        protectedoverridevoid Dispose(bool disposing)[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        {[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            if (disposing && (components != null))[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            {[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]                components.Dispose();[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            }[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            base.Dispose(disposing);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        }[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]#region Windows Form Designer generated code[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        ///<summary>[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        /// Required method for Designer support - do not modify[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        /// the contents of this method with the code editor.[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        ///</summary>[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        privatevoid InitializeComponent()[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        {[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.tbx1 = new System.Windows.Forms.TextBox();[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.button1 = new System.Windows.Forms.Button();[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.tbx2 = new System.Windows.Forms.TextBox();[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.SuspendLayout();[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // [/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // tbx1[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // [/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.tbx1.Location = new System.Drawing.Point(69, 26);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.tbx1.Name = "tbx1";[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.tbx1.Size = new System.Drawing.Size(282, 20);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.tbx1.TabIndex = 0;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.tbx1.TextChanged += new System.EventHandler(this.tbx1_TextChanged);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // [/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // button1[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // [/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.button1.Location = new System.Drawing.Point(144, 94);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.button1.Name = "button1";[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.button1.Size = new System.Drawing.Size(150, 35);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.button1.TabIndex = 1;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.button1.Text = "Concatenar";[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.button1.UseVisualStyleBackColor = true;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.button1.Click += new System.EventHandler(this.button1_Click);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // [/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // tbx2[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // [/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.tbx2.Location = new System.Drawing.Point(69, 164);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.tbx2.Name = "tbx2";[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.tbx2.Size = new System.Drawing.Size(281, 20);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.tbx2.TabIndex = 2;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // [/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // Form1[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // [/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.ClientSize = new System.Drawing.Size(441, 264);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.Controls.Add(this.tbx2);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.Controls.Add(this.button1);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.Controls.Add(this.tbx1);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.Name = "Form1";[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.Text = "Form1";[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.Load += new System.EventHandler(this.Form1_Load);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.ResumeLayout(false);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            this.PerformLayout();[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        }[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]#endregion[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        private System.Windows.Forms.TextBox tbx1;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        private System.Windows.Forms.Button button1;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        private System.Windows.Forms.TextBox tbx2;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]    }[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]}[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000][/COLOR][/SIZE] 
    [SIZE=2][COLOR=#000000]e do trabalho e este:[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]using System;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]using System.Collections.Generic;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]using System.ComponentModel;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]using System.Data;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]using System.Drawing;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]using System.Linq;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]using System.Text;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]using System.Windows.Forms;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]namespace WindowsFormsApplication1[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]{[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]    publicpartialclassForm1 : Form[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]    {[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        public Form1()[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        {[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            InitializeComponent();[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        }[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        string[] x;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        string[] y;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        int i;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        string result = String.Empty;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        privatevoid Form1_Load(object sender, EventArgs e)[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        {[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            MessageBox.Show("Bem Vindo ao programa nomes", "Concatena nomes!!!");[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        }[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        privatevoid tbx1_TextChanged(object sender, EventArgs e)[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        {[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            x = tbx1.Text;[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        }[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        privatevoid button1_Click(object sender, EventArgs e)[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        {[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // Separa os nomes[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            string[] x = x.Split(' ');[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // Pega no Ultimo nome[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            result = x[x.Length - 1];[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // Pega no Primeiro nome[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            result += ", " + x[0] + " ";[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            // Pega nas iniciais dos nomes restantes [/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            for (int i = 1; i < x.Length - 1; i++)[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            {[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]                result += x[i][0] + ". ";[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            }[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]            tbx2 = (result);[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]        }[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]    }[/COLOR][/SIZE]
    [SIZE=2][COLOR=#000000]}[/COLOR][/SIZE]
    
    so nao sei onde esta o erro se me ajudarem desde ja o muito obrigado:(
     
    Última edição pelo moderador: 8 de Dezembro de 2008
  2. The_True_Eue

    The_True_Eue Power Member

    Podias dizer quais são os problemas?
     

Partilhar esta Página