Properly Organizing The Class?

Aug 9, 2010

I am creating a class that represents a vehicle of some kind, called "Transporter". The number of wheels the vehicle has is variable, and is stored in a property. I want the wheels themselves to have their own properties, individually. How do I properly set up a class that is nested within another class? Right now I have two separate classes, where one of the vehicles' properties is a collection(of WheelModule). I just want an outsider opinion, as I have never done this before.

VB.net
Private ModuleCountVal As Integer
<Description("Number of Wheel Modules")> _
Property ModuleCount() As Integer

[code].....

View 16 Replies


ADVERTISEMENT

How To Properly Open A Image Using Bitmap Class And Dispose It Properly

Jun 22, 2010

I am looking for a code snippet which opens a image, creates a clone of this bitmap in memory disposes this opened image so that all handles are closed.

Usually we can open a bitmap using this[code...]

the following code however keeps the Image File locked until the application is running, any suggestions how to dispose it properly. (So that no handle is left open )

Things i already tried: use dispose method of bitmap <= doesnt work (need to write implementation)
Using Block also doesnt work.

View 2 Replies

Columnorder Saving Class Does Not Work Properly?

Feb 23, 2012

I found a class that saves column order and column width for a list view but i cant get it to work properly.

Public Class cListviewHelper
Private Declare Function ListViewiColumnOrder Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal Msg As Integer, ByVal wParam As Integer, ByRef lParam As Integer) As Integer[code].....

It saves the right number of columns but not in the order they are.It always saves them like this in the registry "0,1,2,3,4,5,6"

View 8 Replies

Organizing Command Line Output?

Jul 21, 2009

I have a program that runs a command line and retrieves the output, but the output I receive is unorganized and run-on. Since 3 processes are being run, I'd like each process results to be listed on a different line.

Here is the code:
Dim viewteam = Page.Request.Form("viewteam")
Dim arg As String = "/c net localgroup hglocal-" & viewteam & "-gold"
Dim arg2 As String = "/c net localgroup hglocal-" & viewteam & "-rw"

[Code].....

View 1 Replies

Organizing The Contents Of A .resources File?

Sep 4, 2011

I've been working on a calculation program and it needs to access both a list of constants and a list of variables. So far during development I've used local .txt files and read from them using a StreamReader that accesses them directly using the full path.Obviously that won't work for a published version as there's no guarantee that the files will ever be put in the same place so I'm looking for a way around that.

I've managed to get the constants file converted into a .resources file but the conversion seems to have changed the order of the constants, ie: Pi was first in the original file but is now second. The rearrangement doesn't seem to be alphabetical either as the next pair of entries start with s before we move back to p. Is there any way to force resgen to preserve the order of the elements? Is there a different method I should use?

View 7 Replies

C# - Organizing .NET P/Invoke Code To Win32 APIs?

Mar 12, 2010

I am refactoring a large and complicated code base in .NET that makes heavy use of P/Invoke to Win32 APIs. The structure of the project is not the greatest and I am finding DllImport statements all over the place, very often duplicated for the same function, and also declared in a variety of ways:The import directives and methods are sometimes declared as public, sometimes private, sometimes as static and sometimes as instance methods. My worry is that refactoring may have unintended consequences but this might be unavoidable.

My instict is to organize a static/shared Win32 P/Invoke API class that lists all of these methods and associated constants in one file... EDIT There are over 70 imports to the user32 DLL.(The code base is made up of over 20 projects with a lot of windows message passing and cross-thread calls. It's also a VB.NET project upgraded from VB6 if that makes a difference.)

View 6 Replies

VS 2010 Organizing Images Based On Size

Jun 22, 2012

My program utilizes various images of different sizes. I want to organize these images so that they all fit into a predetermined space without resizing any of them. They need to be organized in such a way to use as much of the predetermined space as possible. I guess it would be like organizing photos in one of those old photo albums (with the translucent, mildly adhesive, peel-back plastic sheet that held the photos in place) so that you could get as many photos on a page as possible. Or you could think of it sort of like Tetris? Except all the pieces are rectangles.

I assume I would use a recursive function to loop through all the images to find out if they fit or not, then returning the best outcome? I tried searching for code samples but searching for Organizing Images or Organizing Shapes gives less than desirable results.

View 5 Replies

VS 2008 Organizing Information From A Text File In A List?

Feb 8, 2012

I'm trying to make a program so I can open a text file, take the information in that file, and organize it in a list, but I can't figure out how to do it exactly.In visual basic, how would I change this:

<NAME>Joe Somebody</NAME>

into:

Joe Somebody

I want to be able to ignore "<NAME>" and "</NAME>" and output "Joe Somebody" into the organized list, but I don't want it to work only with Joe Somebody. I want it to work with other names too. I also want to be able to edit that information, and export it the same way as the text file.

View 1 Replies

Class C Inherits Class D Is Class D A Superclass Or Parent Of Class C?

Dec 16, 2009

If Class X is within the scope of Class Y, is X a subclass of Y?If Class A is a sub Class of B, then is Class B considered a super class of A?if Class C inherits Class D is Class D a superclass or parent of Class C?if Class E extends Class F then we can consider Class E a child of F?if Class G inherits Class H and is within the scope of Class I then who is the parent of Class G? Classes that inherits Class J and classes that are within Class J are all sub classes of Class J?

View 1 Replies

Form Inheritance - Error1Base Class 'MenuStrip' Specified For Class 'Lesson2' Cannot Be Different From The Base Class

Apr 15, 2010

I have put this code in the global form Inherits System.Windows.Forms.Form. And then in the form that will inherit this from the global Inherits MenuStrip. "MenuStrip" is what the global form is called. But keep getting this error: Error1Base class 'MenuStrip' specified for class 'Lesson2' cannot be different from the base class 'System.Windows.Forms.Form' of one of its other partial types.

View 5 Replies

Register The Class File - Not Recognizing My Class.Even The Intellisense Is Not Picking Up Te Class

Jul 22, 2011

I have a class (see below)

Imports Microsoft.VisualBasic
Imports System.Data.SqlClient

Public Class ClientProfile

#Region "Variables"

[CODE]...

It is in the file ClientProfile I have placed in both App_Code and also App_Code/Models

In my code behind I have the following

[CODE]...

The last word, "ClientProfile" has the scary squiggly red line below it. It is not recognizing my class.Even the Intellisense is not picking up te class. Do I have to register the class file in any way?

View 4 Replies

C# - Get The Type For A Class By Sending Just The Name Of The Class Instead Of The Class Itself As The Parameter?

Sep 11, 2009

Dim a as Type=GetType(className) would gimme the type. But I have only the name of the class as string. I want something like GetType("class1") which would return the type.

View 2 Replies

Can't Make Difference Between Public Class And Private Class And Friend And Protected Friend Class

May 15, 2009

I can't make difference between public class and private class and friend and protected friend class.

View 1 Replies

Overload Operator In Generic Class With Generic Interface Of Super Class And Inherit Class?

Jan 21, 2010

I can do this without problem.

Class A
End Class
Class B : Inherit A
End Class
Dim Obj1 As A = New B

View 4 Replies

.net - How To Use Bitvector32 Properly

Dec 23, 2010

I have

Dim bv As New Specialized.BitVector32(25)
Dim sb As String = "0b" 'I resisted the urge to use a stringbuilder
For i As Integer = 31 To 0 Step -1

[Code]....

I only wanted to use BitVector32 for bit flags and I wanted the output to be

0b00000000000000000000000000011001

How do I set this up properly?

View 2 Replies

Using The 'And' Operator Properly?

Apr 8, 2010

In the project�s btnReadNumber click event handler, replace the code in the try section of the try/catch block � the two if statements and the unconditionally executed code � with one if-else statement that performs the same tasks. Use the And operator to write the if-statement�s condition.What I don't understand is how am I supposed to use the 'And' operator so that when I insert a number between 32-16384 in the text box it'll allow it to go through and at the same time not allow any numbers lower than 32(lower_bound) and higher than 16384(upper_bound) to go through.I've use the 'Or' operator and that was simple, but with 'And' I'm not understanding it.Remember it has to be with the 'AND' operator. I bold the area where my problem is at. It's obviously not the right answer, but that's where I was stumped.

Dim sum As Integer = 0
Const upper_bound As Integer = 16384
Const lower_bound As Integer = 32

[code]....

View 4 Replies

Value Not Saving Properly

Feb 15, 2012

Value not saving properly [code]...

View 4 Replies

*.txt Filter Not Working Properly?

Mar 14, 2011

In my word processor I have an 'Open' option on a menu strip. Here is the code for it:

Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
With ofdFile
.Title = "Select a file to open"[code]....

For some reason when I press the 'Open' item and open the ofdFile dialog box .txt files do not appear even when I have the 'Text Files' filter selected However, when I use the 'All Files' filter they appear. And the 'HTML Files filter is also working properly.Why are the .txt files not appearing when I use the Text Files filter?

View 4 Replies

.NET 2.0 .settings Not Working Properly?

Oct 18, 2011

I don't even know where to begin describing this. I have a project, that uses settings, for some paths, settings that I retrieve with the My.Settings. function.In my laptop, when I change the .exe.config file, the settings are updated accordingly, but when I try that on the production server, it just shows the default value used while compiling.

I tried changing the solution configurations to debug and other custom configs with no effect.Tried to use the same folder copied and pasted without version control, still the same result.Tried a co-workers laptop, by using the last svn revision, it works there too. But on neither of the servers works.

View 1 Replies

ArrayList Indexes Not Set Properly?

Aug 25, 2010

I have some basic code to fill items in an ArrayList as follows:

Dim intSteps As ArrayList = New ArrayList()
elect Case Session("type")
Case 1

[code]....

View 2 Replies

Asp.net - Boolean Not Setting Properly?

Mar 3, 2011

I have the following code in an Asp.Net user control:

Me.pnlAddComment.Visible = MyBase.Associate.IsAgent()
Me.lblRating.Visible = Me.pnlAddComment.Visible
Me.Rating1.Visible = Me.pnlAddComment.Visible

Now when I run this code, the value of MyBase.Associate.IsAgent() is true. Yet at no point is Me.pnlAddComment.Visible evaluating to true. When I output the results as Response.Write statements, it shows IsAgent = True, pnlAddComment.Visible = False. When I run it in debug mode, placing the line break on the second line above to allow the set to occur: I put the mouse over IsAgent and it displays "True"; I put the mouse over pnlAddComment.Visible and it displays "False".

A Co-worker suggested that it's possible that it's Panel.Visible black box code in the getter that allows the assignment to occur but returns false because some parent object is set (at that point in the code execution) to False. I've reviewed the parent objects and at no time do any of them appear to be set to not visible.

If this were a reference type I might be convinced that some other process is modifying the reference between this assignment and when it is actually used (at Render), but this is happening right at this line of code.What would cause this boolean assignment to behave this way without throwing an exception?

Solution:The answer turned out to be a parent object in the control hierarchy located outside of the user control itself. Since nothing was explicitly set to false, and I agreed with @Shadow Wizard, @Damien_The_Unbeliever and @CodeMonkey1 that it had to be some outside control influencing the panel at that point, I decided to put a recursive while loop to test the parent of each user control in the hierarchy at that point:

Dim o as Object = Me.pnlAddComment.Parent
While o IsNot Nothing
Me.lblMessage.Text &= "<br />" & o.ID & ": " & o.Visible.ToString()
o = o.Parent
End While

Then I just ran this on the server and the output came back with the full visibility of each control in the chain. What ended up occurring is that this control was contained within a view control within a MultiView. This view control is expected to be visible as it is supposed to be the ActiveView for this particular call, but at the point in the life cycle when my code is run, the view has not been identified as the active view. Since it's not officially active, the view is implicitly false, and all child controls return a value of false when Visible is queried.

The rest of the assignments behave as expected from that point. The lblRating control is set to false (permanently) because at that moment the proper visibility setting for pnlAddComment is false. The lesson I've learned here is not to make control visibilities dependent on each other in this fashion when there is an alternative (and just as simple) method.

View 3 Replies

Assemblies Not Being Loaded Properly?

Sep 19, 2009

I have a windows forms Application using DCOM to connect to another server in order to retrieve data from a database. The program works perfectly fine on my develeopment box both inside of and outside of the idea.However it throws an exception on my test box: System.Exception.... TYPE_E_CANTLOADLIBRARY. The error happens when accessing a property of on the the public DCOM classes. The property holds an instance of one of the private classes for the DCOM. I've compared the registries and all the relevant entries seem to be the same. When I compared the dumps I noticed that System.Config and System.XML werent loaded on the test machine, even though they are installed and appear to be in the GAC.

[Code]...

View 6 Replies

Calculations Not Working Properly?

Apr 17, 2012

I cannot figure out why my calculation is not working. I am doing for 1 to 12 and it gives me 12 inputs but counts my entries as 13? What am I missing. If I change it to 0 to 11 same thing. I am not sure what the issue is, but I cannot see it, and am not sure where to look.I need to end up with 12 cycles through and intEntries to be 12.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'initialize accumulator
Dim decEntries As Decimal[code].......

View 1 Replies

Can't Order The Data Properly

Sep 15, 2010

I have a VB.Net 2008/Access 2007 app that I can�t get to display data in an organized way on a listview. The listview displays the data in the order that the data was entered in the products table. In the SQL statement that loads the listview I put ORDER BY SupplierTbl.CompanyName but it doesn't do it. The listview shows the data in the order that the records were entered in the database. So then I was going to settle for if I can get the listview sorted by clicking on the column header.If I can get that to work then that would be acceptable. So I then implemented the sort routine. The sort works and it doesn't.If you click on a column header then all the rows show the information nicely. The database has an OLE object column for storing images. Customer wants images stored in the database not file paths. When you click the listview the image displays in a picturebox.

The proper images display when the listview is clicked when I use the SQL statement below without the ORDER BY. But when I click on a column header and reorder the display it's no good. If you click on a row in the listview the wrong image is being displayed. It displays them in the order as they were in before the sort. All the other columns look good and are behaving except for the Image column. So that then makes me wonder if my original problem with the ORDER BY is directly related with the OLE object column. Is there something about this data type that I need to know to manipulate it in SQL? My reaction is that maybe since this column is resource heavy it goes by different rules. Can someone please tell me what I need to do to make the end result have some order? This is the SQL statement without the ORDER BY:

command.CommandText = "SELECT ProductTbl.ProductID, ProductTbl.PartNumber, " & _
" ProductTbl.AltPartNumber, ProductTbl.Description, ProductTbl.SupplierID, " & _
" SupplierTbl.SupplierID, SupplierTbl.CompanyName, ProductTbl.Category, " & _

[code]....

View 2 Replies

Can't Resize Font Properly

May 29, 2010

I have a timer program. Initially, the font for the time is the correct size, and when I click "start", the time is the right size too(I had set the initial size to 26 in the properties menu). When I click "break", once the time is up, it displays "Break Over!!" to fit the label(because I changed the font size). Then when I click "start" again, the font has shrunken, even though I set it back to the original size of 26. Why is the font size for the timer not back to it's original size when I click "start" after I have clicked "break"?[code]...

View 2 Replies

Cannot Decrypt PDF Files Properly

Dec 26, 2011

I'm joining several files and would like to encrypt them with AES. As a test I'm joining the exact same file twice, but I'm never able to properly decrypt the second file.

Steps to reproduce:
Make sure you have a file "C:Original.pdf" or change the filepath.

1) Click Button1 to encrypt the file. This will create an encrypted file named "Encrypted.bin"

2) Click Button2 to decrypt the file. This will create a decrypted file named "Decrypted.pdf"
Both "Original.pdf" and "Decrypted.pdf" are 100% the same.

3) Uncomment the code between the hash character lines.

4) Repeat the first two steps.
"Original.pdf" and "Decrypted.pdf" are now not the same.

vb.net
Private enc As New Encrypt
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Encrypt
enc.EncryptDecrypt("C:Original.pdf", "C:Encrypted.bin", True)
[Code] .....

View 1 Replies

Cannot Read A File Properly?

Feb 22, 2009

I'm in need of a simple Regular Expression that will match all strings that start with the string "textures/". The problem probably is when to end the match.

Here is an example of the type of file I need to parse:

[Code]...

I have attached an example file (it's from a game, and it's a free game, so I don't think this is not allowed?). When opening that with Notepad I see loads of spaces and a few strange characters. When opening it with Wordpad, I see mostly strange characters (but the "textures/..." strings I need are still there). When reading it with VB (IO.File.ReadAllText or using a StreamReader) I cannot get it to show more than a few random characters, and the "textures/..." strings are no longer there...

View 12 Replies

Cannot Set Primary Key Properly For Table

May 8, 2012

After days of labouring, debugging and researching, im on the 3rd to last line and im stuck. This isnt the full code, but the relevant parts.

Dim dbProvider As String
Dim dbSource As String
Dim con As New OleDb.OleDbConnection

[Code].....

I understand this means my table doesnt have a primary key, but i have set one.

View 1 Replies

Ctype Not Working Properly?

Nov 1, 2009

dim testpanel as new panel
dim test as CType(testpanel, Control))
msgbox(typename(test)) ' it gives me "panel"

'i dun get it, how can typename of test give me Panel when i explicitly call it to be converted to a Control type?

View 9 Replies

E.KeyCode Not Working Properly?

Jul 4, 2011

So I opened 2 forms, Form2.vb and Form3.vbNow I put this:

Private Sub Form1_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles Me.PreviewKeyDown
If e.KeyCode = Keys.F8 Then

[code].....

View 8 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved