Tutorial [Lớp học lập trình] Bài 3: Project SSH All In One - Part 1 2 3

laintuv

Junior
Joined
May 17, 2014
Messages
40
Reactions
22
MR
0.000
XHBWVQL.png

Mình làm y hệt video mà sao lại bị lỗi này nhỉ? @tunvit
 

chrome47

Junior
Joined
Jun 25, 2015
Messages
153
Reactions
69
MR
0.023
Tất nhiên sẽ được, bài sau trong khi làm mình sẽ nói về class. Yên tâm là sẽ có đầy đủ các kiến thức tương đương bậc cao đẳng hoặc các giáo trình hiện hành. Chỉ là mình ko thích dạy theo lối mòn, rất nhàm chán, thay vì vậy chúng ta cứ làm project, trong lúc làm đụng tới cái nào dạy cái đó, từ từ sẽ biết hết ;)
đúng rồi anh, em cũng đang học IT nhưng ở trường dạy rất là chán + buồn ngủ nên em chả bao giờ đụng tới, thời gian rãnh roàn mò AutoIT vì nó thực tiễn hơn nhiều, bây giờ nhờ có anh mà em có hứng thú lại với C,C#,C++,... Cảm ơn a nhiều nhiều :D:D
 
Mọi người cho mình hỏi là mình làm sai chỗ nào mà nó không lọc được SSH hư vậy ?
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SSH_All_In_One
{
  public partial class Form1 : Form
  {
  public Form1()
  {
  InitializeComponent();
  }
  private void Form1_Load(object sender, EventArgs e)
  {

  }
  private void richTextBox1_TextChanged(object sender, EventArgs e)
  {

  }
  private void richTextBox2_TextChanged(object sender, EventArgs e)
  {

  }
  private void label1_Click(object sender, EventArgs e)
  {

  }
  private void label2_Click(object sender, EventArgs e)
  {

  }   
  private void label3_Click(object sender, EventArgs e)
  {

  }
  private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  {
  //if (comboBox1.SelectedIndex == 0)
  //{
  //  MessageBox.Show("Loc SSH hu !");
  //}
  //else if (comboBox1.SelectedIndex == 1)
  //{
  //  MessageBox.Show("Loc SSH trung ca user va password");
  //}
  }
  private void button1_Click(object sender, EventArgs e)
  {
  if(cbTacVu.SelectedIndex == 0)
  {
  Loc_SSH_Hu();
  }
  else
  {
  MessageBox.Show("Cac chuc nang khac se som co :)");
  }
  //MessageBox.Show("Thuc hien tac vu");
  }
  public void Loc_SSH_Hu()
  {
  string[] danh_sach_Nhap_Vap = txtDauVao.Text.Trim().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
  for (int i = 0; i < danh_sach_Nhap_Vap.Length; i++)
  {
  string ssh = danh_sach_Nhap_Vap[i];
  if (string.IsNullOrEmpty(ssh) == false)
  {
  string[] ssh_Array = ssh.Split('|');
  if (ssh_Array.Length >= 3)
  {
  txtDauRa.Text += ssh + Environment.NewLine;
  //MessageBox.Show("SSH" + ssh + "la SSH loi");
  }
  }
  }
  }
  }
}
 

thanh858036

Banned
Joined
May 16, 2012
Messages
121
Reactions
15
MR
0.000
Mọi người cho mình hỏi là mình làm sai chỗ nào mà nó không lọc được SSH hư vậy ?
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SSH_All_In_One
{
  public partial class Form1 : Form
  {
  public Form1()
  {
  InitializeComponent();
  }
  private void Form1_Load(object sender, EventArgs e)
  {

  }
  private void richTextBox1_TextChanged(object sender, EventArgs e)
  {

  }
  private void richTextBox2_TextChanged(object sender, EventArgs e)
  {

  }
  private void label1_Click(object sender, EventArgs e)
  {

  }
  private void label2_Click(object sender, EventArgs e)
  {

  }  
  private void label3_Click(object sender, EventArgs e)
  {

  }
  private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  {
  //if (comboBox1.SelectedIndex == 0)
  //{
  //  MessageBox.Show("Loc SSH hu !");
  //}
  //else if (comboBox1.SelectedIndex == 1)
  //{
  //  MessageBox.Show("Loc SSH trung ca user va password");
  //}
  }
  private void button1_Click(object sender, EventArgs e)
  {
  if(cbTacVu.SelectedIndex == 0)
  {
  Loc_SSH_Hu();
  }
  else
  {
  MessageBox.Show("Cac chuc nang khac se som co :)");
  }
  //MessageBox.Show("Thuc hien tac vu");
  }
  public void Loc_SSH_Hu()
  {
  string[] danh_sach_Nhap_Vap = txtDauVao.Text.Trim().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
  for (int i = 0; i < danh_sach_Nhap_Vap.Length; i++)
  {
  string ssh = danh_sach_Nhap_Vap[i];
  if (string.IsNullOrEmpty(ssh) == false)
  {
  string[] ssh_Array = ssh.Split('|');
  if (ssh_Array.Length >= 3)
  {
  txtDauRa.Text += ssh + Environment.NewLine;
  //MessageBox.Show("SSH" + ssh + "la SSH loi");
  }
  }
  }
  }
  }
}
dòng này
Code:
string[] danh_sach_Nhap_Vap = txtDauVao.Text.Trim().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
nên thay bằng dòng này dễ hiểu hơn
Code:
string[] danh_sach_Nhap_Vap = richTextBox1.Text.Trim().Split(Environment.NewLine.ToCharArray());
 

smallboy

Junior
Joined
Jul 21, 2015
Messages
246
Reactions
150
MR
0.000
dòng này
Code:
string[] danh_sach_Nhap_Vap = txtDauVao.Text.Trim().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
nên thay bằng dòng này dễ hiểu hơn
Code:
string[] danh_sach_Nhap_Vap = richTextBox1.Text.Trim().Split(Environment.NewLine.ToCharArray());
String[] danh_sach_Nhap_Vap = richTextBox1.Lines();

ngắn gọn xúc tích :D
 

Announcements

Today's birthdays

Forum statistics

Threads
423,888
Messages
7,134,580
Members
176,354
Latest member
thaobroker

Most viewed of week

Most discussed of week

Most viewed of week

Most discussed of week

Back
Top Bottom