3 Replies - 10912 Views - Last Post: 26 March 2009 - 02:53 PM Rate Topic: -----

#1 emblair5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-January 09

coding an array of structure

Posted 26 March 2009 - 12:42 PM

Hello,

I am once again struggling with my weekly project. I am assigned to write a program that converts a predetermined english sentence to both french and german. The code is to contain an Array and a structure. Also we have not covered retrieving array data from a TXT file, so we are to hard code in the array data. I coded the structure and the array, I added the array data, but am confused how to access the data. The examples I have found all deal with retrieving data from a TXT file. Can someone give me a nudge in the right direction. Thank you in advance.


Public Class frmTranslator
	
	'Unit 4 project
	Structure Language

		Dim english As String
		Dim french As String
		Dim german As String

	End Structure

	Dim mywords(45) As Language
	
	Private Sub btnTranslate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTranslate.Click

								mywords(0).english = "YES"
		mywords(0).french = "OUI"
		mywords(0).german = "JA"
		mywords(1).english = "TABLE"
		mywords(1).french = "TABLE"
		mywords(1).german = "TISCH"
		mywords(2).english = "THE"
		mywords(2).french = "LA"
		mywords(2).german = "DEM"
		mywords(3).english = "IS"
		mywords(3).french = "EST"
		mywords(3).german = "IST"
		mywords(4).english = "YELLOW"
		mywords(4).french = "JAUNE"
		mywords(4).german = "GELB"
		mywords(5).english = "FRIEND"
		mywords(5).french = "AMI"
		mywords(5).german = "FREUND"
		mywords(6).english = "SICK"
		mywords(6).french = "MALADE"
		mywords(6).german = "KRANK"
		mywords(7).english = "MY"
		mywords(7).french = "MON"
		mywords(7).german = "MEIN"
		mywords(8).english = "LARGE"
		mywords(8).french = "GROS"
		mywords(8).german = "GROSS"
		mywords(9).english = "NO"
		mywords(9).french = "NON"
		mywords(9).german = "NEIN"
		mywords(10).english = "HAT"
		mywords(10).french = "CHAPEAU"
		mywords(10).german = "HUT"
		mywords(11).english = "PENCIL"
		mywords(11).french = "CRAYON"
		mywords(11).german = "BLEISTIFT"
		mywords(12).english = "RED"
		mywords(12).french = "ROUGE"
		mywords(12).german = "ROT"
		mywords(13).english = "ON"
		mywords(13).french = "SUR"
		mywords(13).german = "AUF"
		mywords(14).english = "AUTO"
		mywords(14).french = "AUTO"
		mywords(14).german = "AUTO"
		mywords(15).english = "OFTEN"
		mywords(15).french = "SOUVENT"
		mywords(15).german = "OFT"










End Sub
End Class

This post has been edited by emblair5: 26 March 2009 - 12:47 PM


Is This A Good Question/Topic? 0
  • +

Replies To: coding an array of structure

#2 LemonMan  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 15
  • View blog
  • Posts: 170
  • Joined: 22-August 05

Re: coding an array of structure

Posted 26 March 2009 - 01:26 PM

If you have code like this which is not an array:

	Structure Language

		Dim english As String
		Dim french As String
		Dim german As String

	End Structure



you can't treat it as an array.

Try using a List (Of String) like this:

Dim german As New List (Of String)

german.Add("Word 1")


'To get word one:

Dim Word1 As String = german(0) 'because it is a zero based list



Was This Post Helpful? 0
  • +
  • -

#3 emblair5  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-January 09

Re: coding an array of structure

Posted 26 March 2009 - 02:32 PM

I understand that a structure is not an array, but part of the assignment is to use a structure and an array. I'm not sure how to tie it all together into a language conversion program.


View PostLemonMan, on 26 Mar, 2009 - 12:26 PM, said:

If you have code like this which is not an array:

	Structure Language

		Dim english As String
		Dim french As String
		Dim german As String

	End Structure



you can't treat it as an array.

Try using a List (Of String) like this:

Dim german As New List (Of String)

german.Add("Word 1")


'To get word one:

Dim Word1 As String = german(0) 'because it is a zero based list



Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2270
  • View blog
  • Posts: 9,496
  • Joined: 29-May 08

Re: coding an array of structure

Posted 26 March 2009 - 02:53 PM

Method
  • Split the text into words
  • For each word in those words
  • Find the location of the from langauge
  • Add the corisponding word in to langauge
  • Repeat for other words
  • Display translation
Work out how to do each step, the connect together
Was This Post Helpful? 1

Page 1 of 1