How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

brottmaye

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by brottmaye » Fri, 03 Sep 2010 15:32:02

How do I go about understanding and converting the coding of .NET 2.0 into the coding that Visual Basic 2005 Express Edition can understand



Renee

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by Renee » Sun, 05 Sep 2010 16:33:03

.Net V2.0 is a framework for languages. VB.Net uses that framework. There is not such thing (other than ILASM) as "coding of .Net 2.0", therefore, I am confused by your question.



brottmaye

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by brottmaye » Mon, 06 Sep 2010 18:35:05

private void updateNumberLabel()
{
//we get index of first visible char and
//number of first visible line
Point pos = new Point(0, 0);
int firstIndex = richTextBox1.GetCharIndexFromPosition(pos);
int firstLine = richTextBox1.GetLineFromCharIndex(firstIndex);

//now we get index of last visible char
//and number of last visible line
pos.X = ClientRectangle.Width;
pos.Y = ClientRectangle.Height;
int lastIndex = richTextBox1.GetCharIndexFromPosition(pos);
int lastLine = richTextBox1.GetLineFromCharIndex(lastIndex);

//this is point position of last visible char, we'll
//use its Y value for calculating numberLabel size
pos = richTextBox1.GetPositionFromCharIndex(lastIndex);

//finally, renumber label
numberLabel.Text = "";
for (int i = firstLine; i <= lastLine + 1; i++)
{
numberLabel.Text += i + 1 + "\n";
}

}

And etc...

That's basically the source code for the .NET 2.0 and i would like to
use this for my visual basic 2005 express edition program that i am
creating and i don't know how to convert it into a readable vb 2005 ee
source code format. Thanks for helping me with this.



spott

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by spott » Tue, 07 Sep 2010 17:34:04

Perhaps If you show use what coding you are talkign about we may be able to assist.

As renee quite rightly said the .NET framework is an underlying managed framework which many languages can use. The most popular of which are VB.NET and C#. However there are actually many other languages which use the .NET framework.

These application compile the high level languages into something called IL (Intermediate Langauge) which is similar to Assembler. But a much lower level language which you can view if you use something like ILDASM to disassemble a VB.NET application. This IL when it gets run actually is processed by a (Just In Time) JIT compiler to make it run.


Renee

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by Renee » Wed, 08 Sep 2010 19:36:06

 

That's basically the source code for the .NET 2.0

 No, this is simple C#. It is not the source code for .NET 2.0. Instead, it is designed to run supported by DOT NET 2.0. There's a big difference.

Ok I'm  not a C# expert by any means but here is my translation

private sub updateNumberLabel()

    'we get index of first visible char and     
    'number of first visible line
    Dim pos as point = new Point(0, 0)
    Dim firstIndex as integer = richTextBox1.GetCharIndexFromPosition(pos)
    Dim firstLine as integer = richTextBox1.GetLineFromCharIndex(firstIndex)    
    'now we get index of last visible char  and number of last visible line   
    ' Client rectangle defined somewhere else     Obviously it's the client rectangle  of the RTB
    pos = new point ( ClientRectangle.Width,    ClientRectangle.Height  )      
    Dim lastIndex as integer = richTextBox1.GetCharIndexFromPosition(pos)
    Dim lastLine as integer = richTextBox1.GetLineFromCharIndex(lastIndex)    
    'this is point position of last visible char, we'll  use its Y value for calculating numberLabel size   
    pos = richTextBox1.GetPositionFromCharIndex(lastIndex)
    'finally, renumber label   
    numberLabel.Text = ""  
    for i as integer = firstLine to lastLine + 1  
             numberLabel.Text += i + 1 + "\n"
    next
end sub

Note: I'm not sure of the "\n"  = the vb translation may very well be environment.newline

Or

VBCrLf

 



Renee

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by Renee » Thu, 09 Sep 2010 21:38:08

I'm not totally sure of this, but I think this it right........

Private Sub Form1_Load(ByVal sender As Object, _

ByVal e As System.EventArgs) Handles Me.Load

numberLabel.Font = New Font(RichTextBox1.Font.FontFamily, _

RichTextBox1.Font.Size + 1.019F) ' I think..

End Sub

Private Sub richTextBox1_VScroll(ByVal sender As Object, ByVal e As System.EventArgs) _

Handles RichTextBox1.VScroll

'move location of numberLabel for amount

'f pixels caused by scrollbar

numberLabel.Location = New Point(0, _

RichTextBox1.GetPositionFromCharIndex(0).Y _

Mod (RichTextBox1.Font.Height + 1))

updateNumberLabel()

End Sub



brottmaye

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by brottmaye » Fri, 10 Sep 2010 20:37:07

Could you possibly figure out these next two for me. That would be great. THANKS!

public NumberedTextBoxUC()
{
InitializeComponent();

numberLabel.Font = new Font(richTextBox1.Font.FontFamily,
richTextBox1.Font.Size + 1.019f);
}

private void richTextBox1_VScroll(object sender, EventArgs e)
{
//move location of numberLabel for amount
//of pixels caused by scrollbar
int d = richTextBox1.GetPositionFromCharIndex(0).Y %
(richTextBox1.Font.Height + 1);
numberLabel.Location = new Point(0, d);

updateNumberLabel();
}



spott

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by spott » Sat, 11 Sep 2010 22:39:09

You should check out - the following 2 utilities which will convert snippets of C# code to VB.

http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx

http://www.kamalpatel.net/ConvertCSharp2VB.aspx

This way you can do you own conversions of whatever code you using.


Renee

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by Renee » Mon, 13 Sep 2010 00:41:11

Hmmmmm Kalmal has gotten better..........

Private Sub updateNumberLabel()
'we get index of first visible char and
'number of first visible line
Dim pos As Point = New Point(0,0)
Dim firstIndex As Integer = richTextBox1.GetCharIndexFromPosition(pos)
Dim firstLine As Integer = richTextBox1.GetLineFromCharIndex(firstIndex)
'now we get index of last visible char
'and number of last visible line
pos.X = ClientRectangle.Width
pos.Y = ClientRectangle.Height
Dim lastIndex As Integer = richTextBox1.GetCharIndexFromPosition(pos)
Dim lastLine As Integer = richTextBox1.GetLineFromCharIndex(lastIndex)
'this is point position of last visible char, we'll
'use its Y value for calculating numberLabel size
pos = richTextBox1.GetPositionFromCharIndex(lastIndex)
'finally, renumber label
numberLabel.Text = ""
Dim i As Integer
For i = firstLine To lastLine + 1 Step i + 1
numberLabel.Text += i + 1 + "\n"
Next
End Sub

'----------------------------------------------------------------
' Converted from C# to VB .NET using CSharpToVBConverter(1.2).
' Developed by: Kamal Patel (http://www.KamalPatel.net)
'----------------------------------------------------------------



Renee

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by Renee » Mon, 13 Sep 2010 23:40:10

Spotty,

I find these sites to be highly fallable. Rarely will they translate user generated code. On the OP's first request, I tried to use them and they received errors as per usual and produced mostly C#. That's why I resorted to translating them myself.



SJWhitele

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by SJWhitele » Wed, 15 Sep 2010 01:42:12

Those sites I've used occasionally. Yes, they do a pretty good job but are not infallable - there's no substitute for understanding the language :)

DMan

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by DMan » Thu, 16 Sep 2010 03:44:14

Note: I'm not sure of the "\n" = the vb translation may very well be environment.newline

Or

VBCrLf

That is correct '\n' is the syntax for newline in C#



brottmaye

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by brottmaye » Fri, 17 Sep 2010 02:43:13

Renee What is the Mod function, I am getting a syntax error on that code. Thanks.



Renee

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by Renee » Sat, 18 Sep 2010 04:45:15

I dimly remembered that...but I don't like to acknowledge any knowledge of C/

Shhhhhhhhhhhh



Renee

How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

by Renee » Mon, 20 Sep 2010 05:46:16

Did Kalman make an error or did I

For i = firstLine To lastLine + 1 Step i + 1

This doesn't look right to me.