Visual Basic 2010 automatically changes indentation of my code from this ::
public void fetchWebserviceCounters() {
csv = new StringBuilder();
try {
Category = new PerformanceCounterCategory("Web Service");
foreach (String instance in Category.GetInstanceNames()) {
counters = Category.GetCounters(instance);
foreach (PerformanceCounter counter in counters) {
if (counter.CounterName == "Total Bytes Sent" | counter.CounterName == "Total Bytes Recieved") {
csv.Append(counter.CounterName + ",");
csv.Append(counter.NextValue().ToString() + ", ");
}
}
}
}
catch (Exception e) {
Console.WriteLine(e.Message);
}
Console.Write(csv.ToString());
}
to this
public void fetchWebserviceCounters()
{
csv = new StringBuilder();
try
{
Category = new PerformanceCounterCategory("Web Service");
foreach (String instance in Category.GetInstanceNames())
{
counters = Category.GetCounters(instance);
foreach (PerformanceCounter counter in counters)
{
if (counter.CounterName == "Total Bytes Sent" | counter.CounterName == "Total Bytes Recieved")
{
csv.Append(counter.CounterName + ",");
csv.Append(counter.NextValue().ToString() + ", ");
}
}
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
Console.Write(csv.ToString());
}
How can i prevent Visual Basic from Doing this to My code
If you’re passing C# to Visual Basic editor expect it to mess up.
There are lots of text formatting options in VS: Tools | Options | Text Editor | language | Formatting.
The extent of these depends on the language, and includes options about when code is automatically re-formatted.