brottmayer

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



Re: Visual Basic Express Edition How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

ReneeC

.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.






Re: Visual Basic Express Edition How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

spotty

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.





Re: Visual Basic Express Edition How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

brottmayer

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.





Re: Visual Basic Express Edition How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

ReneeC

 

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

 






Re: Visual Basic Express Edition How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

brottmayer

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();
}






Re: Visual Basic Express Edition How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

ReneeC

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






Re: Visual Basic Express Edition How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

spotty

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.





Re: Visual Basic Express Edition How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

ReneeC

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.






Re: Visual Basic Express Edition How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

ReneeC

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)
'----------------------------------------------------------------






Re: Visual Basic Express Edition How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

SJWhiteley

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 :)




Re: Visual Basic Express Edition How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

brottmayer

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






Re: Visual Basic Express Edition How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

DMan1

ReneeC wrote:

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#






Re: Visual Basic Express Edition How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

ReneeC

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

Shhhhhhhhhhhh






Re: Visual Basic Express Edition How do I convert .NET 2.0 Coding into VB 2005 Express Edition coding?

ReneeC

Did Kalman make an error or did I

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

This doesn't look right to me.