i want to call a void from other form. there is no error when i called void from same form. when i called from another form it return "index was out of range" error
namespace browser
{
public partial class mainF : Form
{
int bo;
public List<string> home = new List<string>();
public mainF()
{
InitializeComponent();
string[] lineurl = File.ReadAllLines(cupath + "\\db.txt");
foreach (string line in lineurl)
{
if (line != "") { home.Add(line); }
}
bo = -1;
}
private void button1_Click(object sender, EventArgs e)
{
pembalik();
label1.Text = initialing.curHome;
}
public void pembalik()
{
bo += 1;
initialing.curHome = home[bo]; ////index error here when called from other form
domainmaker(initialing.curHome);
initialing.domain = domain;
linkopen open = new linkopen();
open.show();
}
private void domainmaker(string hook)
{
domain = hook.Substring(0, hook.LastIndexOf("/") + 1);
}
}
public class initialing
{
public static string __domain = "";
public static string __cur = "";
public static string domain
{
get { return _domain; }
set { _domain = value; }
}
public static string curHome
{
get { return _cur; }
set { _cur = value; }
}
}
}
i try call pembalik() from this form
namespace browser
{
public partial class linkopen : Form
{
public linkopen()
{
InitializeComponent();
label1.Text = label1.Text.Substring(0,label1.Text.IndexOf(":")+1)+ initialing.curHome;
label2.Text = label2.Text.Substring(0,label2.Text.IndexOf(":") + 1) + initialing.domain;
}
private void button1_Click(object sender, EventArgs e)
{
mainF a = new mainF();
a.pembalik();
this.close();
}
}
}