[Question] Make function accessible from any codefile in project menu

User Tag List

Results 1 to 4 of 4
  1. #1
    -Ryuk-'s Avatar Elite User CoreCoins Purchaser Authenticator enabled
    Reputation
    529
    Join Date
    Nov 2009
    Posts
    1,028
    Thanks G/R
    38/51
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Question] Make function accessible from any codefile in project

    Hello

    I have this in my Form1.cs:

    Code:
             public void msg1(string msgtype, string Message)
            {
    
                string time = DateTime.Now.ToShortTimeString();
                String res = "[" + time + "] " + Message;
                int selectionStart = richTextBox1.TextLength;
                richTextBox1.AppendText(res + Environment.NewLine);
                // OR rtbTestResult.Text += res + Environment.NewLine;
                richTextBox1.SelectionStart = selectionStart;
                richTextBox1.SelectionLength = res.Length;
                //Set colour(0=Red|1=Green|2=Black)
                if (msgtype == "0")
                {
                    richTextBox1.SelectionColor = Color.Red;
                    richTextBox1.ScrollToCaret();
                }
                else if (msgtype == "1")
                {
                    richTextBox1.SelectionColor = Color.Green;
                    richTextBox1.ScrollToCaret();
                }
                else if (msgtype == "2")
                {
                    richTextBox1.SelectionColor = Color.Black;
                    richTextBox1.ScrollToCaret();
                }
                
            }
    I want to access it from codefile1.cs. but:

    Code:
    msg1("2","test message");
    Doesn't work.

    So I tired changing:
    Code:
    public void msg1(string msgtype, string Message)
    to:
    Code:
    static public void msg1(string msgtype, string Message)
    but now richTextBox1 has the red line under it to show an error, like this:


    the error shows:


    Any help please?
    |Leacher:11/2009|Donor:02/2010|Established Member:09/2010|Contributor:09/2010|Elite:08/2013|

    [Question] Make function accessible from any codefile in project
  2. #2
    snigelmannen's Avatar Member
    Reputation
    27
    Join Date
    Jul 2007
    Posts
    318
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Read through the code 3 - 100 times and see what you did wrong? You obviously made something wrong as it only runs as you programmed it too.
    " Spy sappin mah sentry! "

  3. #3
    -Ryuk-'s Avatar Elite User CoreCoins Purchaser Authenticator enabled
    Reputation
    529
    Join Date
    Nov 2009
    Posts
    1,028
    Thanks G/R
    38/51
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its working as it was originally intended ^^
    |Leacher:11/2009|Donor:02/2010|Established Member:09/2010|Contributor:09/2010|Elite:08/2013|

  4. #4
    ReidE96's Avatar Archer Authenticator enabled
    Reputation
    470
    Join Date
    Dec 2006
    Posts
    1,625
    Thanks G/R
    1/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheap n' nasty workround is to have a Form1 object created when the program starts as a global, then run that .msg1

Similar Threads

  1. Making Money IRL From WoW or other games Questions
    By PurpleFog in forum World of Warcraft General
    Replies: 4
    Last Post: 07-02-2016, 10:44 PM
  2. Replies: 7
    Last Post: 12-19-2009, 11:45 AM
  3. Question: How to change from priv. serv to blizzards?
    By Bridude in forum World of Warcraft General
    Replies: 5
    Last Post: 03-21-2007, 10:07 PM
  4. Out from any battleground without deserter!
    By needmorerep in forum World of Warcraft Exploits
    Replies: 1
    Last Post: 11-01-2006, 07:20 AM
  5. Raid Griefing Exploit (kick anyone from any group)
    By Matt in forum World of Warcraft Exploits
    Replies: 5
    Last Post: 04-28-2006, 09:26 AM
All times are GMT -5. The time now is 11:22 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search