473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Snagged on New Create Object

geo039
47
Okay I have an application, which is to demonstrate the use of a created class. I have a previous and next button which cycles through the array. However I need the user to be able to create a new instance of the object then as they cycle through they see their new object. I am stuck on this part. I've tried a few things for my button create event but I have been getting an unhandled can't convert to 1 dimensional array among other things. Any tips and help would be appreciated.

Expand|Select|Wrap|Line Numbers
  1. Public Class frmMain
  2.     Inherits System.Windows.Forms.Form
  3.  
  4.     Private m_objName(2) As Course     ' Client object
  5.     Private m_intPosition As Integer = 0 ' current account
  6.  
  7. Private Sub frmMain_Load(ByVal sender As System.Object, _
  8.         ByVal e As System.EventArgs) Handles MyBase.Load
  9.  
  10.         Dim intCount As Integer ' counter variable
  11.  
  12.         ' array of course names
  13.         Dim strCourseName() As String = _
  14.            New String() {"Science", "History", "Math"}
  15.  
  16.         ' array of course numbers
  17.         Dim strCourseNumber() As String = _
  18.            New String() {"S123", "H123", "M123"}
  19.  
  20.         'array of start date 
  21.         Dim strStartDate() As String = _
  22.            New String() {"2/27/07", "2/28/07", "3/1/07"}
  23.  
  24.         'array of start date 
  25.         Dim strEndDate() As String = _
  26.            New String() {"4/10/07", "4/11/07", "4/12/07"}
  27.  
  28.         ' loop and create more course objects
  29.         For intCount = 0 To m_objName.GetUpperBound(0)
  30.  
  31.             ' create new object and store into Client array
  32.             m_objName(intCount) = New Course(strCourseName(intCount), _
  33.                strCourseNumber(intCount), strStartDate(intCount), _
  34.                strEndDate(intCount))
  35.         Next
  36.     End Sub
  37.  
  38.     Private Sub btnNext_Click(ByVal sender As System.Object, _
  39.         ByVal e As System.EventArgs) Handles btnNext.Click
  40.  
  41.         m_intPosition += 1 ' increment position
  42.  
  43.         ' if position is last (top) object
  44.         If m_intPosition > m_objName.GetUpperBound(0) Then
  45.             m_intPosition = 0    ' set to first position in array
  46.             DisplayInformation() ' display information
  47.         Else
  48.             DisplayInformation()
  49.         End If
  50.  
  51.     End Sub
  52.  
  53.     Private Sub btnPrev_Click(ByVal sender As System.Object, _
  54.         ByVal e As System.EventArgs) Handles btnPrev.Click
  55.  
  56.         m_intPosition -= 1 ' decrement position
  57.  
  58.         ' if position is last (bottom) object
  59.         If m_intPosition < 0 Then
  60.  
  61.             ' set to last position in array
  62.             m_intPosition = m_objName.GetUpperBound(0)
  63.             DisplayInformation()
  64.         Else
  65.             DisplayInformation() ' display information
  66.         End If
  67.  
  68.     End Sub
  69.  
  70.     ' display information
  71.     Private Sub DisplayInformation()
  72.  
  73.         ' use m_intPosition as index for each object
  74.         txtCourseName.Text = m_objName(m_intPosition).Name
  75.         txtCourseNumber.Text = m_objName(m_intPosition).Number
  76.         txtCourseStart.Text = _
  77.            Convert.ToString(m_objName(m_intPosition).Start)
  78.         txtCourseEnd.Text = _
  79.            Convert.ToString(m_objName(m_intPosition).CEnd)
  80.  
  81.  
  82.     End Sub ' DisplayInformation
  83.  
  84.     Private Sub btnCreate_Click(ByVal sender As System.Object, _
  85.         ByVal e As System.EventArgs) Handles btnCreate.Click
  86.  
  87.  
  88.  
  89.     End Sub
  90. End Class ' frmMain
Mar 1 '07 #1
1 1323
kenobewan
4,871 Expert 4TB
I believe that you will need to store the arrays values, in a file or db table, then update and reload page binding data to arrays.
Mar 4 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: jon wayne | last post by:
OK! I had this nagging doubt Consider (without worrying abt access specifiers) class Kid : public Parent{...}; Parent::someFunc() { Kid k; }
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
2
by: Just D. | last post by:
All, Do we have a simple way to Create an object on the fly knowing just an object type? The usual design-time way is to write a code something like this: CObjectType obj = new CObjectType();...
37
by: Steven Bethard | last post by:
The PEP below should be mostly self explanatory. I'll try to keep the most updated versions available at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
18
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt...
27
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB...
10
by: SM | last post by:
Hello I'm trying to create a multi dimensional array in JavaScript, but after some reading i still can't figure out how to apply it to my model. Here it is: I have a list A and for each item...
1
by: Dave | last post by:
I have multiple forms that will create an object. Basically a energy efficiency measure object. The measure object will have a couple of required properties set but after that it can have 10-20...
2
by: Immortal_Nephi | last post by:
Sometimes, programmers decide to create only one object. One object is used for a whole program. You can run two or more programs at the same time. Each program has a copy of its own object....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.