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
  1. Home
  2. General Programming
  3. C#
  4. Why doesn´t work the Code?

Why doesn´t work the Code?

Scheduled Pinned Locked Moved C#
questioncomsysadminhelp
11 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nhqlbaislwfiikqraqnm
    wrote on last edited by
    #1

    Hallo! What is the problem? I have the Server and Client form here http://board.gulli.com/thread/141481...t-fhig-machen/[^] So it works the fully code, i can open Word,Ecxel and shutdown in x sec. f (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } And so it do nothing! string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel");

    P M K 3 Replies Last reply
    0
    • N nhqlbaislwfiikqraqnm

      Hallo! What is the problem? I have the Server and Client form here http://board.gulli.com/thread/141481...t-fhig-machen/[^] So it works the fully code, i can open Word,Ecxel and shutdown in x sec. f (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } And so it do nothing! string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel");

      P Offline
      P Offline
      padmanabhan N
      wrote on last edited by
      #2

      no one can understand your problem....:confused:

      PC17 wrote:

      What is the problem?

      are you asking us to run the code and check the error and tell it to you.... :doh: please be a bit clear so that our experts can slove your problem and giude you in a correct way........ :)

      Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

      N 1 Reply Last reply
      0
      • P padmanabhan N

        no one can understand your problem....:confused:

        PC17 wrote:

        What is the problem?

        are you asking us to run the code and check the error and tell it to you.... :doh: please be a bit clear so that our experts can slove your problem and giude you in a correct way........ :)

        Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

        N Offline
        N Offline
        nhqlbaislwfiikqraqnm
        wrote on last edited by
        #3

        OK Sorry The first code i have posted works! And the Second is the same but the Array is in the end!This code doesn´t work!

        P 1 Reply Last reply
        0
        • N nhqlbaislwfiikqraqnm

          Hallo! What is the problem? I have the Server and Client form here http://board.gulli.com/thread/141481...t-fhig-machen/[^] So it works the fully code, i can open Word,Ecxel and shutdown in x sec. f (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } And so it do nothing! string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel");

          M Offline
          M Offline
          musefan
          wrote on last edited by
          #4

          you getting a compiler error? or runtime? what about the second '}'? is that in the wrong place? hard to tell without the opening code

          Life goes very fast. Tomorrow, today is already yesterday.

          1 Reply Last reply
          0
          • N nhqlbaislwfiikqraqnm

            Hallo! What is the problem? I have the Server and Client form here http://board.gulli.com/thread/141481...t-fhig-machen/[^] So it works the fully code, i can open Word,Ecxel and shutdown in x sec. f (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } And so it do nothing! string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel");

            K Offline
            K Offline
            Keith Barrow
            wrote on last edited by
            #5

            Do you have an example value for "get" ? Also System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); will shut the machine down if called, not Word or Excel.

            N 1 Reply Last reply
            0
            • N nhqlbaislwfiikqraqnm

              OK Sorry The first code i have posted works! And the Second is the same but the Array is in the end!This code doesn´t work!

              P Offline
              P Offline
              padmanabhan N
              wrote on last edited by
              #6

              are you getting any error... because in your sample the first method and the second method both are same... the only difference is the ifstatement goes last and the arrar comes first...

              Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]

              1 Reply Last reply
              0
              • K Keith Barrow

                Do you have an example value for "get" ? Also System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); will shut the machine down if called, not Word or Excel.

                N Offline
                N Offline
                nhqlbaislwfiikqraqnm
                wrote on last edited by
                #7

                It´s difficut to explain it! I have a Server and a Client. the Client have many Buttons for examble open Word , shutdown,... When i use this code in the Server i can click on open Word or shutdown both works! if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } When i use this code where the sring[] is on the front place i can´t open word! but i can shutdown the Pc in x sec!? string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); Why is that so that only the one command work?

                L K P 3 Replies Last reply
                0
                • N nhqlbaislwfiikqraqnm

                  It´s difficut to explain it! I have a Server and a Client. the Client have many Buttons for examble open Word , shutdown,... When i use this code in the Server i can click on open Word or shutdown both works! if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } When i use this code where the sring[] is on the front place i can´t open word! but i can shutdown the Pc in x sec!? string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); Why is that so that only the one command work?

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #8

                  PC17 wrote:

                  It´s difficut to explain it!

                  I can't imagine why it would be difficult. Just give us the facts, with all the relevant details, and you'll get an answer. Read my sig. Here are just a few of the unclear points: - are client and server on the same machine? if not: - where is winword or excel to run? how is the client involved? - which machine should shutdown? the server? can any client tell the server to shutdown? And you should publish code inside PRE tags, that way you would have seen yourself that at least one of your code snippets will not even compile. Read my sig. :)

                  Luc Pattyn [Forum Guidelines] [My Articles]


                  The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.


                  1 Reply Last reply
                  0
                  • N nhqlbaislwfiikqraqnm

                    It´s difficut to explain it! I have a Server and a Client. the Client have many Buttons for examble open Word , shutdown,... When i use this code in the Server i can click on open Word or shutdown both works! if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } When i use this code where the sring[] is on the front place i can´t open word! but i can shutdown the Pc in x sec!? string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); Why is that so that only the one command work?

                    K Offline
                    K Offline
                    Keith Barrow
                    wrote on last edited by
                    #9

                    Aha! Now I understand. The problem is with these lines

                    string\[\] get\_Split = get.Split('~');
                    int time = Convert.ToInt32(get\_Split\[1\]);
                    

                    Take the example of starting word. get is "rWord" get_Split will have length 1 ie: get_Split[0] = "rWord" the line int time = Convert.ToInt32(get_Split[1]); tries to access an array element that doesn't exist get_Split[1], this will throw an error. This will work

                    if (get == "rWord")
                    System.Diagnostics.Process.Start("winword");
                    if (get == "rExcel")
                    System.Diagnostics.Process.Start("excel");
                    if (get.Contains("rshutdown"))
                    {
                    string[] get_Split = get.Split('~');
                    int time = Convert.ToInt32(get_Split[1]);
                    System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString());
                    }

                    1 Reply Last reply
                    0
                    • N nhqlbaislwfiikqraqnm

                      It´s difficut to explain it! I have a Server and a Client. the Client have many Buttons for examble open Word , shutdown,... When i use this code in the Server i can click on open Word or shutdown both works! if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } When i use this code where the sring[] is on the front place i can´t open word! but i can shutdown the Pc in x sec!? string[] get_Split = get.Split('~'); int time = Convert.ToInt32(get_Split[1]); if (get.Contains("rshutdown")) { System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString()); } } if (get == "rWord") System.Diagnostics.Process.Start("winword"); if (get == "rExcel") System.Diagnostics.Process.Start("excel"); Why is that so that only the one command work?

                      P Offline
                      P Offline
                      Pete OHanlon
                      wrote on last edited by
                      #10

                      The two pieces of code aren't actually the same. You haven't just moved the string[] array, you've also moved the second }. Try this to see if it has any effect:

                      string[] get_Split = get.Split('~');
                      int time = Convert.ToInt32(get_Split[1]);
                      if (get.Contains("rshutdown"))
                      {
                      System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString());
                      }
                      if (get == "rWord")
                      System.Diagnostics.Process.Start("winword");
                      if (get == "rExcel")
                      System.Diagnostics.Process.Start("excel");
                      }

                      "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                      As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                      My blog | My articles | MoXAML PowerToys | Onyx

                      N 1 Reply Last reply
                      0
                      • P Pete OHanlon

                        The two pieces of code aren't actually the same. You haven't just moved the string[] array, you've also moved the second }. Try this to see if it has any effect:

                        string[] get_Split = get.Split('~');
                        int time = Convert.ToInt32(get_Split[1]);
                        if (get.Contains("rshutdown"))
                        {
                        System.Diagnostics.Process.Start("shutdown", "-s -t " + time.ToString());
                        }
                        if (get == "rWord")
                        System.Diagnostics.Process.Start("winword");
                        if (get == "rExcel")
                        System.Diagnostics.Process.Start("excel");
                        }

                        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                        My blog | My articles | MoXAML PowerToys | Onyx

                        N Offline
                        N Offline
                        nhqlbaislwfiikqraqnm
                        wrote on last edited by
                        #11

                        @keefb Thank you, you have understand my problem! now i can open Word and so when i put the code on the Front place! But now this code doesn´t work! if (get == "rshutdown_without_warning") System.Diagnostics.Process.Start("shutdown", "-s -t 0"); if (get == "rshutdown_abort") System.Diagnostics.Process.Start("shutdown", "-a"); thank you at all!!! EDIT: I don´t know why but it works! Thank you at everybody, it´s a very good forum, there are a lot of very clever people! :thumbsup::thumbsup:

                        modified on Thursday, August 20, 2009 4:22 PM

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

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