Hey people
im learning c# and was wondering what the equivalents are of functions in VB 6 like
i looked on google but cant see much about themVB Code:
chr() asc() now() mid() split() left() right() strreverse()
Printable View
Hey people
im learning c# and was wondering what the equivalents are of functions in VB 6 like
i looked on google but cant see much about themVB Code:
chr() asc() now() mid() split() left() right() strreverse()
chr() - ?
asc() - ?
now() - DateTime.Now
mid() - myString.SubString(5,3)
split() - myString.Split(" ")
left() - myString.SubString(0, 5)
right() - myString.SubString(myString.Length - 5)
strreverse() - ?
Sorry I don't know the others off the top of my head. Look at the different functions you can do with a string variable. This will lead you to answering what you need answered. There is also the System.Text namespace, or the char data type that allows other things.
Chr()
Convert.ToString(65)
Asc()
Convert.ToByte('A')
a couple more Chr variations ...
VB Code:
char chr = (char)65; // same as Chr(65) char chr1 = Convert.ToChar(65); // same as Chr(65)
i dug out a function i made ages ago in C# for reversing strings , here ya go...
PHP Code:private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show(StringReverse("test 123"));
}
private string StringReverse(string ToReverse)
{
Array arr = ToReverse.ToCharArray();
Array.Reverse( arr ); // reverse the string
char[] c = (char[])arr;
byte[] b = System.Text.Encoding.Default.GetBytes(c);
return System.Text.Encoding.Default.GetString(b);
}