11 Replies - 1830 Views - Last Post: 10 August 2011 - 02:50 PM Rate Topic: -----

#1 gryphin   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 138
  • Joined: 29-October 05

VB Class issue (class file, not school class)

Posted 09 August 2011 - 03:59 PM

Ok, so I used to mess around with C#, just a little. And someone had helped me make a class for Visual C# that was supposed to do the math parts for "internal structure" - which the program used for a part of its calculations and screen... Basically there were 2 options. Endo-Steel and Standard. The user would use a updownbox to determine weight of the machine and then internal structure was a % of that total. If it was standard then it was 10% of the overall weight, if it was Endo-Steel then it was 50% of standard (so 5% of total weight) rounded to next 0.5 (so .25 was .5, 1.25 was 1.5, 1.75 was 2.0, etc). I have the code for the C# class file for it, but want to make it in VB... Can someone help with translating it? Preferably piece by piece so that I can learn as I go through it...

C# class file -
 using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Mech_Editor
{
    class InternalStructure
    {
        public decimal[,] endoSteel = new decimal[,] 
        {
            {20m, 1}, 
            {25m, 1.5m}, 
            {30m, 1.5m},
            {35m, 2.0m},
            {40m, 2.0m},
            {45m, 2.5m},
            {50m, 2.5m},
            {55m, 3.0m},
            {60m, 3.0m},
            {65m, 3.5m},
            {70m, 3.5m},
            {75m, 4.0m},
            {80m,4.0m},
            {85m,4.5m},
            {90m,4.5m},
            {95m,5.0m},
            {100m,5.0m}
        };
 
        public decimal standardInternalStucture(decimal tonnage)
        {
            return tonnage * .10M;
        }

        public decimal endoSteelInternalStructure(decimal tonnage)
        {
            decimal result = 0;
            for (int counter = 0; counter <= endoSteel.Length; counter++)
            {
                if (endoSteel[counter, 0] == tonnage)
                {
                    result = endoSteel[counter, 1];
                    break;
                }
            }
            return result;
        }

        public List<string> InternalStructureTypes()
        {
            StreamReader structure = new StreamReader(System.Windows.Forms.Application.StartupPath + @"\internalStructureTypes.txt");

            List<string> skeleton = new List<string>();

            while (!structure.EndOfStream)
            {
                skeleton.Add(structure.ReadLine());
            }

            structure.Close();

            return skeleton;
        }
    }
}


For VB I know they use Imports instead of Using... So I assume at the very least I need "Imports System.IO". What about the other imports/usings?

Is This A Good Question/Topic? 0
  • +

Replies To: VB Class issue (class file, not school class)

#2 AdamSpeight2008   User is offline

  • MrCupOfT
  • member icon

Reputation: 2298
  • View blog
  • Posts: 9,535
  • Joined: 29-May 08

Re: VB Class issue (class file, not school class)

Posted 09 August 2011 - 04:27 PM

Mm what about you do some basic research first?
You can start by reexamining the code you've provided. Are there any other namespaces being imported?

What are the basic differences in the grammar between C# and VB.net?

Why not also research why code written and compiled by .net language can be utilized by any other .net langauge?


Dream.In.Code is not a on demand code writing service. We are here to assist in helping other fellow students in our profession develop the skills, they will need to progress.

Refactored down to the Core skills of Research and the Scientific Method


We'll help once you've at least attempted doing the conversion yourself.

This post has been edited by AdamSpeight2008: 09 August 2011 - 04:28 PM

Was This Post Helpful? 0
  • +
  • -

#3 trevster344   User is offline

  • The Peasant
  • member icon

Reputation: 225
  • View blog
  • Posts: 1,526
  • Joined: 16-March 11

Re: VB Class issue (class file, not school class)

Posted 09 August 2011 - 05:00 PM

Learning Java really helped me with this, since Java, and C# are similar in code structure.
Was This Post Helpful? 0
  • +
  • -

#4 gryphin   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 138
  • Joined: 29-October 05

Re: VB Class issue (class file, not school class)

Posted 09 August 2011 - 08:18 PM

View PostAdamSpeight2008, on 09 August 2011 - 05:27 PM, said:

Dream.In.Code is not a on demand code writing service. We are here to assist in helping other fellow students in our profession develop the skills, they will need to progress.


Last time I read my post, I do not remember asking for the code. I specifically was trying to do research and find out the differences in plain english as opposed to places like MSDN where it is written for people who know the stuff already.

Perhaps you can actually read a post instead of making assumptions? I did not ask for code, I asked for differences in gramar and syntax between the 2 so I could translate it. I also specifically mentioned that I had only gotten to 1 import - because I do not know which of the other ones need added and which ones are automatically included (as research has brought up the fact some are and some are not).

I am not asking for it to be recoded, I am asking for differences in the different sections of the code so I can learn it easier and understand it more fully. If I wanted code on demand, I would go to one of those sites and pay for it.
Was This Post Helpful? 0
  • +
  • -

#5 AdamSpeight2008   User is offline

  • MrCupOfT
  • member icon

Reputation: 2298
  • View blog
  • Posts: 9,535
  • Joined: 29-May 08

Re: VB Class issue (class file, not school class)

Posted 09 August 2011 - 09:45 PM

Quote

I am not asking for it to be recoded, I am asking for differences in the different sections of the code so I can learn it easier and understand it more fully. If I wanted code on demand, I would go to one of those sites and pay for it.


Now why don't I believe that? I tell you why from your first post.

Quote

I have the code for the C# class file for it, but want to make it in VB... Can someone help with translating it? Preferably piece by piece so that I can learn as I go through it...


You ask for some to write all the code for you.

On the imports issue. What so difficult for you open Visual Studio or an Express edition, and see with your own eyes which are imported? It'll take you 5minutes at the most.

What research have you done since you first post the question about find out the differences between the languages? mmm I've just down a quick online search and found at least 2 website that are not MSDN that covers the subject matter.

Have you considered download the Basic Quick Reference Guide of both languages, available in the respective tutorial sections. There also links to both languages language specifications.

This post has been edited by AdamSpeight2008: 09 August 2011 - 09:49 PM

Was This Post Helpful? 1
  • +
  • -

#6 gryphin   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 138
  • Joined: 29-October 05

Re: VB Class issue (class file, not school class)

Posted 10 August 2011 - 08:20 AM

View PostAdamSpeight2008, on 09 August 2011 - 10:45 PM, said:

Quote

I am not asking for it to be recoded, I am asking for differences in the different sections of the code so I can learn it easier and understand it more fully. If I wanted code on demand, I would go to one of those sites and pay for it.


Now why don't I believe that? I tell you why from your first post.

Quote

I have the code for the C# class file for it, but want to make it in VB... Can someone help with translating it? Preferably piece by piece so that I can learn as I go through it...


You ask for some to write all the code for you.

On the imports issue. What so difficult for you open Visual Studio or an Express edition, and see with your own eyes which are imported? It'll take you 5minutes at the most.

What research have you done since you first post the question about find out the differences between the languages? mmm I've just down a quick online search and found at least 2 website that are not MSDN that covers the subject matter.

Have you considered download the Basic Quick Reference Guide of both languages, available in the respective tutorial sections. There also links to both languages language specifications.


Now, why dont you learn to read? I said "I want HELP in TRANSLATING code that I already had in C#. Where does it say "I want someone to recode it for me? If you are here simply to argue, please stop posting on my questions and feel free to stop trying to help me. I am not looking for an idiot to argue with.

And frankly, I do not care what you believe or do not believe.

And instead of picking up on the piece by piece, why not reference the line just before it - HELP TRANSLATING. The piece by piece is that I wanted to do it in sections with someone, so I can learn the most without having to see someone else do it for me. I want someone to help by pointing out items to go over, not do it for me. So next time ask for clarification instead of acting like an idiot.

This post has been edited by gryphin: 10 August 2011 - 08:24 AM

Was This Post Helpful? -3
  • +
  • -

#7 gryphin   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 138
  • Joined: 29-October 05

Re: VB Class issue (class file, not school class)

Posted 10 August 2011 - 08:35 AM

View PostAdamSpeight2008, on 09 August 2011 - 10:45 PM, said:

On the imports issue. What so difficult for you open Visual Studio or an Express edition, and see with your own eyes which are imported? It'll take you 5minutes at the most.


Did you ever think that maybe others did not learn the way you did or have the training and resources you had when you learned how to program? I am looking for more information than just what is in the 1 file I already have... I was looking for help learning about as many of the imports as possible, then I can see what is needed and why they might be needed, not just the ones for this specific spot. It was a general question about what is able to be done automatically and what needs imports.

View PostAdamSpeight2008, on 09 August 2011 - 10:45 PM, said:

Have you considered download the Basic Quick Reference Guide of both languages, available in the respective tutorial sections. There also links to both languages language specifications.


If not for the rest of your posting, it would have been a useful one - why not just say something like this next time? This was something I could have used. Do you have any specific recommendations for quick reference guides?

Next time instead of insulting the poster, maybe ask him/her to clarify intentions... You are being rude, uncooperative, and in general non-productive.

This post has been edited by JackOfAllTrades: 11 August 2011 - 04:58 AM

Was This Post Helpful? 0
  • +
  • -

#8 trevster344   User is offline

  • The Peasant
  • member icon

Reputation: 225
  • View blog
  • Posts: 1,526
  • Joined: 16-March 11

Re: VB Class issue (class file, not school class)

Posted 10 August 2011 - 08:40 AM

View Postgryphin, on 10 August 2011 - 08:20 AM, said:

View PostAdamSpeight2008, on 09 August 2011 - 10:45 PM, said:

Quote

I am not asking for it to be recoded, I am asking for differences in the different sections of the code so I can learn it easier and understand it more fully. If I wanted code on demand, I would go to one of those sites and pay for it.


Now why don't I believe that? I tell you why from your first post.

Quote

I have the code for the C# class file for it, but want to make it in VB... Can someone help with translating it? Preferably piece by piece so that I can learn as I go through it...


You ask for some to write all the code for you.

On the imports issue. What so difficult for you open Visual Studio or an Express edition, and see with your own eyes which are imported? It'll take you 5minutes at the most.

What research have you done since you first post the question about find out the differences between the languages? mmm I've just down a quick online search and found at least 2 website that are not MSDN that covers the subject matter.

Have you considered download the Basic Quick Reference Guide of both languages, available in the respective tutorial sections. There also links to both languages language specifications.


Now, why dont you learn to read? I said "I want HELP in TRANSLATING code that I already had in C#. Where does it say "I want someone to recode it for me? If you are here simply to argue, please stop posting on my questions and feel free to stop trying to help me. I am not looking for an idiot to argue with.

And frankly, I do not care what you believe or do not believe.

And instead of picking up on the piece by piece, why not reference the line just before it - HELP TRANSLATING. The piece by piece is that I wanted to do it in sections with someone, so I can learn the most without having to see someone else do it for me. I want someone to help by pointing out items to go over, not do it for me. So next time ask for clarification instead of acting like an idiot.


This isn't the first time someone's said something to you along this line gryphin. Just rephrase your questions, ask a specific question about translating. what you asked was looking for a hand out unfortunately, but I'm certain if you rephrase someone can help.
Was This Post Helpful? 0
  • +
  • -

#9 biggerB   User is offline

  • Inactive
  • member icon

Reputation: 80
  • View blog
  • Posts: 760
  • Joined: 11-June 10

Re: VB Class issue (class file, not school class)

Posted 10 August 2011 - 09:11 AM

You should try an online code conversion utility, those can really help you in understanding the new code.. Try this one
Was This Post Helpful? 0
  • +
  • -

#10 smohd   User is offline

  • Critical Section
  • member icon


Reputation: 1825
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: VB Class issue (class file, not school class)

Posted 10 August 2011 - 09:40 AM

Quote

This was something I could have used. Do you have any specific recommendations for quick reference guides?

In every homepage of a specific language forum here in DIC, there is a quick reference sheet.

Quote

You should try an online code conversion utility, those can really help you in understanding the new code.. Try this one

and then he will learn nothing except get the already-cooked code.

As AdamSpeight2008 said, I suggested you study every part of the code you have(and if you did those C# code for your self, you already know them) and find out how can I do it in VB.NET. This will help understand the language and not just translate it. Like if I need to add two numbers how can I do it in vb.net?
Was This Post Helpful? 2
  • +
  • -

#11 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: VB Class issue (class file, not school class)

Posted 10 August 2011 - 11:00 AM

We have resources in the tutorials sections you may find helpful:
http://www.dreaminco...mply-explained/
http://www.dreaminco...lass-structure/
Was This Post Helpful? 1
  • +
  • -

#12 AdamSpeight2008   User is offline

  • MrCupOfT
  • member icon

Reputation: 2298
  • View blog
  • Posts: 9,535
  • Joined: 29-May 08

Re: VB Class issue (class file, not school class)

Posted 10 August 2011 - 02:50 PM

For the record. I learnt to program by trail and error, and trying things out.

Admit-tingly it was so long along that the computer came with a programming guides. ZX Spectrum, Acorn Electron. Then got an Acorn A3010, which came with an updated version of BBC Basic built in and came with a basic guide. I save up for the Programmer's Reference Manual (a beast of book, inch and half thick and was shelf bending-ly heavy). Bought a book which covered programming in ARM Assembly, and alos bought a book that covered how to program for the WIMP (Desktop). No GUI Designers here, required manipulating bits and bytes.

If I didn't how to do something, I'd open up a book at the index and look for something that may cover it, find the corresponding section read through it discover it wasn't, so back to the index.

I'll try things out in actual code, by experimenting. What happens if I do this? or that? Is possible to do this if I did it this way. By making loads and loads of mistakes.

I'll tell you good / bad mistake I made and didn't spot until I ran it. Made a slight error in the error handling code, which it turn call the error handler. When you make mistakes that can only be fixed by physically switching off the power to the machine, and you've not saved the hundreds of code. You soon learn good habits and practices.

How would I go about tackling this translation Copy and Paste the code into the VB.net editor.
When the background compiler kicks in it highlight loads of errors (It knows vb.net the best). I'd translate the lines I do know, commenting out the sections I've translated. This will leave me with just the section I don't know, so I'd look at the documentation I have trying to find it.

I'd try out my best guess of what it could be. If I could find it.

Then use some online service. Let's say it was Dream.In.Code I make a new post. Stating what I trying to do, include the original, include my attempt, include a separate section on the difficult part, include what I had tried out (and why it didn't work). Include my assumptions about what the expected result should be, and what they actually results where.

After posting and waiting I'd wouldn't stop doing my research, sometime I go and do something else completely different (like going for a walk or have a sleep). In the meantime should I happen upon an answer (may not be the best solution) I add a reply (note I don't delete the original post) explaining what I had discovered, so other can learn. Hopefully I get a reply which show a better way.


I studied French at school but now I cant speak it and understand the basics, but should I ever go to a place that French is spoken. I take a phrasebook or an English - French Dictionary. I know that my grammar and accent won't be perfect and I'll probably make some embarrassing errors, but I know that I get some respect for at least trying and get better at it.

This post has been edited by AdamSpeight2008: 10 August 2011 - 02:57 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1