Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
A

andredani

@andredani
About
Posts
56
Topics
23
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • .dll issue! VBA to C#?!
    A andredani

    Hi! I´m trying to translate Vba call method from .dll. But if i translate it it won´t be the same in C#. The code in VBA:

    Public Sub SnodAnrop()
    i = Module1.snod25x(host, port, user, pass, cert, cacert, service, arg, extra, result, buf)
    End Sub

    Declare Function snod25x Lib "sn25.dll" Alias "****" (ByVal Host As String, ByVal Port As String, ByVal User As String, ByVal Passwd As String, ByVal Cert As String, ByVal CAert As String, ByVal Nodtjanst As String, ByVal Arg As String, ByVal Extra As String, ByVal Result As String, ByVal Resultbuf As Long) As Long

    The translation to C# have i done like this:

    [DllImport("sn25.dll", EntryPoint = "****")]
    static extern int snod(string host, string port, string user, string passwd, string cert, string CAert, string Nodtjänst, string arg, string extra, string result, int buf); private void button1_Click(object sender, EventArgs e)

    { int i = snod("", "", user, pass, "", "", service, arg, "",result, 1024); } The problem is now is the string "result" in VBA returns info, but in C# it doesn´t collect any info at all. Int i returns a status value wich is 0 that meens OK. The problem is that i dont get any info back with the string "result" in C# How Would u translate it? Have i missed something? Im pretty new in C# so explain easely. Would Appriciate some help!!! Thanks!!!!

    C# help csharp question

  • .dll issue! VBA to C#
    A andredani

    Hi all im trying to convert a .dll call method from VBA to C# VBA Code look like this: Public Sub SnodAnrop() Dim result As String host = "***" port = "***" user = "****" pass = "**" cert = "" cacert = "" service = "**" arg = vTyp & pnr & datumIn & datumUt extra = "" result = Space(1024) buf = 1024 i = Module1.snod25x(host, port, user, pass, cert, cacert, service, arg, extra, result, buf) SnodError (result) If sFel = 0 Then result = GVRSvar(result) WriteToFile (result) End If Declare Function snod25x Lib "sn25.dll" Alias "****" (ByVal host As String, _ ByVal port As String, _ ByVal user As String, _ ByVal passwd As String, _ ByVal cert As String, _ ByVal CAert As String, _ ByVal Nodtjanst As String, _ ByVal arg As String, _ ByVal extra As String, _ ByVal result As String, _ ByVal Resultbuf As Long) As Long And i have come this far in C#: private string result; [DllImport("sn25.dll", EntryPoint = "****")] static extern int snod(string host, string port, string user, string passwd, string cert, string CAert, string Nodtjänst, string arg, string extra, string result, int buf); private void button1_Click(object sender, EventArgs e) { result = new String(' ', 1024); string user = "*****"; string pass = "***"; string service = "GVRPOSDIAP2"; int i = snod("*****", "****", user, pass, "", "", service, textBox1.Text ,"", result, 1024); textBox2.Text = i.ToString(); textBox3.Text = result; } This two code strips are the same. In different language. The Problem is that dont get any result back, its empty, but in the identical code in VBA its returning info at string result. My Question is how can i write the code in C# so a get back info at the string result???? The int i is giving me status back witc

    C# question help csharp

  • Problem with printing a page foreach listview.items
    A andredani

    yes i know.. but i want it to be on print page2 in the same position like page1. Regards!!

    C# graphics help

  • Problem with printing a page foreach listview.items
    A andredani

    Hi all! I´m trying to make a barcodeprinting and to make it possible i have to have a page foreach items in my listview. my code look like this: private void button1_Click(object sender, EventArgs e) { if (checkBox1.Checked == true) { PrintDialog theDialog = new PrintDialog(); theDialog.Document = printDocument1; if (theDialog.ShowDialog() == DialogResult.OK) { printDocument1.DocumentName = listView1.Items.Count.ToString(); printDocument1.PrintPage += new PrintPageEventHandler(this.printDocument1_PrintPage); printDocument1.Print(); } } } private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { foreach (ListViewItem lvi in listView1.Items) { DateTime dt = DateTime.Now; string doktyp = "278"; Font font = new Font("3 of 9 Barcode", 20); int St = Convert.ToInt32(domainUpDown1.Text); Font font1 = new Font("Arial", St); Font font2 = new Font("Arial", 10); float x = 120; float y = 100; e.Graphics.DrawString("Jobb: " + label11.Text, font2, new SolidBrush(Color.Black), x + 500, y - 50); e.Graphics.DrawString("Användare: " + label12.Text, font2, new SolidBrush(Color.Black), x + 500, y - 35); e.Graphics.DrawString(dt.ToString("yyyy-dd-MM HH:mm:ss"), font2, new SolidBrush(Color.Black), x + 500, y - 20); e.Graphics.DrawString("*" + lvi.SubItems[1].Text + "*", font, new SolidBrush(Color.Black), x, y + 85); e.Graphics.DrawString("*" + lvi.SubItems[1].Text + "*", font, new SolidBrush(Color.Black), x, y + 105); e.Graphics.DrawString("*" + lvi.SubItems[1].Text + "*", font, new SolidBrush(Color.Black), x, y + 125); e.Graphics.DrawString(lvi.SubItems[1].Text, font1, new SolidBrush(Color.Black), x, y + 145); } } With this code it overwhrites all the items in one page. Thanks! Best Regards André

    C# graphics help

  • Encoding problem??
    A andredani

    i think its the listview hwo doesn´t display them correclty. beacouse i have tryade every encoding.. are i changing the ecoding throught advanced save options???? Thanks

    C# help question

  • Encoding problem??
    A andredani

    Hi guys! having a bit of a problem.. im picking upp value from file rowes, and i live in sweden so we use the characters å,ä,ö a lot. so i want to replace the å ä ö with something else, because when i return the row in a listview the ö are like ? or something like that... =( i have tryade to save in diffirent encoding.. nothing works! anyone with the same problem as me?? i pick upp info from rowes like this: String row5 = File.ReadAllLines(file)[row]; string[] tecken = row5.Split(';'); string person = tecken[21]; anyone with good suggestions?? thanks!! peace! :doh:

    C# help question

  • How do i trim down a string[] with - 3 letters??
    A andredani

    Hi i trying to search for values in .txt file and return the existings lines But how can i trim down the string[] Chunk to -3 letters?? for example: .txt file look like this # k441122 blabla blabla blabla blabla if i search for k441 than return the k441122 with all the existings lines? i have tryade Chunk.Substring(0 , 4) Any idea?? My code look like this: private bool ReadChunk(StreamReader sr, out string[] Chunk, string MatchData) { Chunk = new string[9]; bool FoundMatch = false; for (int i = 0; i < 9; i++) { try { Chunk[i] = sr.ReadLine(); if (i == 1 && Chunk[i] == MatchData) { FoundMatch = true; } } catch (Exception ex) { FoundMatch = false; } } return FoundMatch; } Big Tnx!!

    C# question tutorial

  • Strange problem with display time
    A andredani

    I all. I have a strange case with display timer my code look like this: Timer myTimer = new Timer(); public static int nr = 1; private void button1_Click(object sender, EventArgs e) { myTimer.Interval = 1000; myTimer.Enabled = true; myTimer.Start(); myTimer.Tick += new EventHandler(myTimer_Tick); } void myTimer_Tick(object sender, EventArgs e) { string a = ""; int tid1 = 0; int tid2 = 0; a = label21.Text; tid1 = Convert.ToInt32(a); tid2 = (int)tid1 - nr; label21.Text = tid2.ToString(); } But if i click on a stop button with:(myTimer.Stop()), then when i press on play button again the string (nr) has change to 2 and next time 3 How do i make this work?? Anyone with a good idea?? Tnx!!!

    C# question help

  • Using streamwriter into xls. file
    A andredani

    ok.. my code to send info from my listview to a .xls file look like this: string[] lines3 = System.IO.File.ReadAllLines("datainställningar.txt"); string path3 = lines3[0]; string text = textBox1.Text; string namn = text + ".xls"; if (MessageBox.Show("Vill du skapa diagramet " + text + "?", "Mitt jobb", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { using (StreamWriter sw = new StreamWriter(path3 + namn)) { for (int listIndex = 0; listIndex < this.listView2.Items.Count; listIndex++) { sw.WriteLine(this.listView2.Items[listIndex].Text + this.listView2.Items[listIndex].SubItems[1].Text + this.listView2.Items[listIndex].SubItems[2].Text + this.listView2.Items[listIndex].SubItems[3].Text); } Process.Start(namn); } } But now it´s writes in only a1 cells in .xls, but i want it to write every subitems in each cell. is it more clearly now?? tnx

    C# help tutorial question

  • Using streamwriter into xls. file
    A andredani

    no.. i just givin my example of what i thought.. this code writes in a .xls file but in one cell. I want to change cells foreach subitems.. how do i do that appreciate this. Big tnx!

    C# help tutorial question

  • Using streamwriter into xls. file
    A andredani

    Hi would appreciate if you helped me with this strange problem. i´m trying to write text from my listview into a excel file but the problem is that i want to change cells, now its writing in the same cell. for example: a1 a2 a3 a4 subitem[0] subitem[1] subitem[2] subitem[3] subitem[0] subitem[1] subitem[2] subitem[3] tryade this: using (StreamWriter sw = new StreamWriter((path3 + namn), true)) { for (int listIndex = 0; listIndex < this.listView2.Items.Count; listIndex++) { sw.WriteLine(this.listView2.Items[listIndex].Text + this.listView2.Items[listIndex].SubItems[1].Text + this.listView2.Items[listIndex].SubItems[2].Text + this.listView2.Items[listIndex].SubItems[3].Text); } Process.Start(namn); enyone with a good knowledge with this problem??? TNX!!;)

    C# help tutorial question

  • Calculate timespan with number?
    A andredani

    If i want to calculate time like this time / pages * 100 = time per 100 pages for example: 00:05:00 / 5 = 00:00:01 * 100 = 00:01:40 Any suggest tnx:)

    C# tutorial question

  • Calculate time with int
    A andredani

    Hi all sorry for asking, but how do i calculate time"hh:mm:ss" / int(pages) *100. for example 00:00:10 / 10 *100 Gonna count the time of 100 pages... big reggards!! Thanks

    C# tutorial question

  • Only look in subfolders..
    A andredani

    tnx man.. but i did like this: System.IO.DirectoryInfo subDI = new System.IO.DirectoryInfo(path); foreach (String sub in Directory.GetDirectories(path)) { foreach (String file in Directory.GetFiles(sub, "*.dat")) { listView2.Items.Clear(); this.toolStripProgressBar1.Value += 10; System.Threading.Thread.Sleep(dimension); int fileCount = System.IO.Directory.GetFiles(sub, "*.*", SearchOption.AllDirectories).Length; String subName = sub.Substring(sub.LastIndexOf(@"\") + 1); DateTime time = DateTime.Now; ListViewItem item = new ListViewItem(new string[] { sort, subName, time.ToString(), "", fileCount.ToString(), "", pris, appl }); this.listView2.Items.Add(item); ListViewItem item2 = new ListViewItem(new string[] { sort, subName, time.ToString(), "", fileCount.ToString(), "", pris, appl }); this.listView3.Items.Add(item2); works just fine.. yet..=) But i got another problem::(( i start a timer with button1 and want to stop it with button2 i thought it could be like this: private void button1_Click(object sender, EventArgs e) { string[] lines1 = System.IO.File.ReadAllLines("inställningar.txt"); string path1 = lines1[8]; string tid = lines1[0]; int dimension = Convert.ToInt32(tid); Timer oT = new Timer(); oT.Tick += new System.EventHandler(TimerFunction); oT.Interval = dimension; oT.Start(); } private void button2_Click(object sender, EventArgs e) { Timer oT = new Timer(); oT.Tick += new System.EventHandler(Timerfunction); oT.Stop(); } But i where wrong!! How would u do it?? tnx!;)

    C# question

  • Stop timer
    A andredani

    Hi, i have one button1 hwo starts the timer: Timer oT = new Timer(); oT.Tick+= new System.EventHandler(TimerFunction); oT.Interval = 15000; oT.Start(); private void TimerFunction(object o, EventArgs e) { //////////my code } My question is how do i stop the timer with a button2 click??? And do u know any good sleep or wait function??? Thanks!!!;);P:(

    C# question

  • Only look in subfolders..
    A andredani

    ok =) gonna try... Way won´t this work?? System.IO.DirectoryInfo subDI = new System.IO.DirectoryInfo(path); foreach (String sub in Directory.GetDirectories(path)) { foreach (String file in Directory.GetFiles(sub, "*.dat")) { int count = 0; for (int i = 0; i < sub.Length; i++) count += System.IO.Directory.GetFiles(sub[i]).Length;:((:(( //// Here!!!! String subName = sub.Substring(sub.LastIndexOf(@"\") + 1); DateTime time = DateTime.Now; ListViewItem item = new ListViewItem(new string[] { sort, subName, time.ToString(), "", count.ToString(), "", pris, appl }); this.listView2.Items.Add(item); this.listView2.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); this.toolStripProgressBar1.Value += 50; sparaform(); } this.toolStripProgressBar1.Value = 0; } Want to getfiles count from subfolder to the path. //thanks man!

    C# question

  • Only look in subfolders..
    A andredani

    I´m trying to tell the path that there are only subfolder that it gonna countfiles and pass subfolder name insted for path name and path filescount... my code works but i want to change that it only will look in subfolders.. And i think my Debug are broke beacause i get error when i use Directory.MoveTo(sub, dest) strange.. says that this file allready exists in dest.. Thanks..!;P

    C# question

  • Only look in subfolders..
    A andredani

    hi how do i change to only look in the path´s subfolders, and move them to (dest)?? And when my program are finished how do i convert my project to a program, witch program do u use?? heres my code: string[] lines = System.IO.File.ReadAllLines("dataapplikationer.txt"); string appl = lines[1]; string path = lines[2]; string sort = lines[5]; string dest = lines[3]; System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(path); { int filesCouunt = dir.GetFiles().Length; string name = dir.Name; DateTime time = DateTime.Now; ListViewItem item = new ListViewItem(new string[] { sort, name, time.ToString(), "Summa tid", filesCouunt.ToString(), "av:", appl }); this.listView2.Items.Add(item); this.listView2.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); //thanks;)

    C# question

  • Delete selected rowes in a listview from .txt file
    A andredani

    if i want to delete the selected row in a list view i use: if (listView1.SelectedItems.Count > 0) { if (MessageBox.Show("Vill du verkligen ta bort denna?", "Mina jobb", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { for (int i = listView1.SelectedItems.Count - 1; i >= 0; i--) listView1.Items.Remove(listView1.SelectedItems); } } But if i want to delete this selected row from a .txt file how do i do that..??? it´s four subitems and the .txt file look like this # blah blablah blabl blaaa //thanks;);P:^):(:sigh::doh:

    C# question

  • Help please! About Listview and .txt file
    A andredani

    the question are: i add this into a listview string ett = "1"; string u = comboBox1.Text; string q = textBox1.Text; string w = textBox2.Text; DateTime dt = DateTime.Now; if (q.Length > 0 && w.Length > 0 && u.Length > 0) { if (this != null) { string time = dt.ToString("dd"); string name = this.textBox1.Text + time.ToString() + ett; ListViewItem item = new ListViewItem(new string[] { u, name, dt.ToString(), this.textBox2.Text }); ListViewIns.Items.Add(item); But string u and name can not be equal with something else in a .txt file for example string u = Online name = k431121 And the .txt file look like this: # online k431121 blah blah If they two string match with line[index +1] an line[index +2] then add +1 on k431121. So in this example they match it will add +1 and look like this # online k431121 blah blah # online k431122 blah blah I have a code but it don´t want to work: private List Entries; private void LoadEntries() { string key; Entries=new List(); foreach (ListViewItem item in listView1.Items) { key = string.Concat(item.SubItems[0], "@@", item.SubItems[1]); if (!Entries.Contains(key)) Entries.Add(key); } } private void PopulateListView(List list) { LoadEntries(); listView1.View = View.Details; listView1.Columns.Add("Kolumn1"); listView1.Columns.Add("Kolumn2"); listView1.Columns.Add("Kolumn3"); listView1.Columns.Add("Kolumn4"); listView1.Columns.Add("Kolumn5"); string Name,No,key; int n; for (int i = 0; i < list.Count; i += 5) { Name = list[i+1]; No = list[i + 2]; while(Entries.Contains(key = string.Concat(Name, "@@", No))) { n = Convert.ToInt32(No.Substring(No.Length - 1)); No = String.Concat(No.Substring(0, No.Length - 1), n + 1); } if (!Entries.Contains(key)) Entries.Add(key); ListViewItem item = new ListViewItem(list[i]); item.SubItems.Add(Name); item.SubItems.Add(No); item.SubItems.Add(list[i + 3]); item.SubItems.Add(list[i + 4]); listView1.Items.Add(item); } } My question is: can you help me build this together..???:sigh: :):-D:laugh: Thanks////

    C# question database regex help tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups