NedFrankly 0 Light Poster

We might think this would be easy to answer. We might be wrong.

First, we have to look at what Structured and Object Oriented mean.

Object Oriented (from WikiPedia http://en.wikipedia.org/wiki/Object_oriented) is:

(an) Object-oriented system is composed of objects. The behaviour of the system is achieved through collaboration between these objects, and the state of the system is the combined state of all the objects in it. Collaboration between objects involves them sending messages to each other. The exact semantics of message sends between objects varies depending on what kind of system is being modelled. In some systems, "sending a message" is the same as "invoking a method".

Structured Programming is a subset of Procedural Programming (Wiki: http://en.wikipedia.org/wiki/Structured_programming). An example is this:

Coders should break larger pieces of code into shorter subroutines (functions, procedures. methods, blocks, or otherwise) that are small enough to be understood easily. In general, programs should use global variables sparingly; instead, subroutines should use local variables and take arguments by either value or reference.

Sounds similar, doesn't it? It is. The major difference is in the language you choose and how you implement these 'things' within the language or framwork. Some languages and frameworks (like .net) are strongly typed Object Oriented languages. EVERYTHING is an object. While a few built-in methods could qualify as procedural, and we often write subroutines that would be indistinguishable from a similar method in a non-OO language, nonetheless in an OO environment we …

NedFrankly 0 Light Poster

That looks good, but you might have to use Ltrim and Rtrim if you have:-

Dim str AsString = "    This  is a   Test and  has eight       words     "

And THIS is why collaborative development is so much fun! Nice catch!

Ned

NedFrankly 0 Light Poster

It's hard to tell what code you want to move to a Function. A couple of things to consider:

If you pass objects to a method BYVAL, you are passing a COPY of the object (i.e. your integer). If you pass an object to a method BYREF you are NOT passing a value, you are passing a pointer to the original variable (and can generally update it from your subroutine). Here's an example:

' This is a simple, byval function.  We'll call it in the mySub method.
private function AddOne(BYVAL AnInteger as INTEGER) as INTEGER
 dim intPlusOne as INTEGER
 intPlusOne = AnInteger + 1
 return intPlusOne
end function
 
' This is a BYREF function.
private SUB AddOneByRef(BYREF AnInteger as INTEGER) 
 AnInteger = AnInteger + 1
end sub
 
' Now we call the methods above.
private sub mySub()
 
' intX starts out as a 5
dim intX as INTEGER = 5
' intX = 5
 
intX is passed ByVal to AddOne.  intX does not change.  
dim intY as INTEGER = AddOne(intX)
' intX = 5, intY=6
 
AddOneByRef(intX)
' intX=5 before the call, intX=6 after the call.  No RETURN is needed.
' We updated the variable 'intX' within the subroutine.
 
end sub

To start, figure out what you want to make repeatable (that's the whole point of creating a method like this). Once you establish that, look at the code to be split out and determine every piece of data that it needs - every variable, every fixed value. Look …

NedFrankly 0 Light Poster

The main thing that I'm worried about is, if I go the route of CE (because people say that CS is boring, and if you get a degree in CE you'll be more of an AI programming, robotics, electrical guy with programming background whereas in CS you'll just have a more deep rooted understanding of computing languages.

I'm worried that if I get a degree in CE, and I want to get a job as a computer programming working as a software engineer, or working at a game company or something, and getting rejected because I have a degree in CE and not CS.

Most of the developers that I work with (Application Development, mostly data mining, data collection (as in field engineering inspection data), and reporting) have masters degrees in Computer Science. That said, one of our best programmers has a degree in US History, my boss is a Forester (and a very good Oracle programmer), I'm an Electronics Engineering dropout... I don't believe that I would ever consider the difference between a CS or a CE degree. What we think about in hiring a programmer is the type of skills and experience the candidate brings to the table. Most companies hiring programmers don't consider the degree to represent skills OR experience - it's proof that you know how to learn. No college teaches programming in the ways that it's actually done in the real world (ask ANYONE who's been out of school for a few years and working …

NedFrankly 0 Light Poster

My problem is....i have done a project in VB.NET with SQL SERVER as the database.
My project was running perfect until last day when i tried to run the project i got some errors.

Errors :

1) Could not copy temporary files to O/P directory

2) The file Call Center.exe cannot be copied to the run directory, this process cannot access the file because its being used by another process

3) The reference component ADODB could not be found, A wrapper assembly is not registered for this type library

4) The refernece component MSAdodc1.ib could not load this type of library,A wrapper assembly is not registered for ths type of library

A few things to try. First, kill your output directories (by this, I mean locate your BIN directories and delete the DLL's and EXE's for your project, both Debug and Release). If things continue to give you problems with 'cannot replace' or 'cannot write' you will need to also remove these DLL's from your GAC (for GAC info: http://www.codeproject.com/dotnet/DemystifyGAC.asp)

Some other things:
Rebuild (versus Build) your assembly. This forces all sub-assemblies to be rebuilt from scratch.

Try setting your Copy Local (under Properties for each Reference) to True (if they are already True, try setting them to False, rebuild (it will fail) and then set True and rebuild.) If this does not work, try removing all of your references and add them back to the project.

Finally, if still No …

NedFrankly 0 Light Poster

From what I can gather, it appears that you cannot access Excel from VB.NET without having Visual Studio 2005 Tools for Office (and a healthy extra sum of money)! Is this really true? There's got to be a way, seeing as you can do it in VB6 without anything extra.
Thanks, OH

OH, you can still use the old Office COM objects via Interop, but you will be running unmanaged code and will have to deal with memory leaks and other issues with some of the older Office dll's. The new Office objects are supposed to address these issues with a set of true native .net objects, but I have not had a chance to play with these yet (still on vs2003). I've coded against the old objects and it's not too horrendous, but it definitely takes some care to prevent it from eating your machine alive at run time.

Search for COM Interop in the Microsoft docs in VS to get started (you'll end up on Google looking for more clarification, but start with MS for the groundwork).

Hope that helps!

Ned

NedFrankly 0 Light Poster

You wouldn't. That fact is using string split or mid or trim will not reliably count words if they are separated with multiple number of spaces.

"              A     sentence      here         "
"A sentence here"

Whereas my example will. (With the exception the words are separated with tabs or newlines instead)
And if that's the case you just write code another condition to take care of that.

Good points, Mr. Iamthwee! The string.Split method does allow you to pass a string Array of 'match' values for your delimiters. While this is a simple problem begging for a simple solution (and yours is straight-forward and easy to understand) for the sake of making my method clear I'll recommend this:

IF you would find use (for scalability, for example) for the Replace / Split mechanism, pre-cleaning the input string would go a LONG way. Something along these lines:

Dim str AsString = "This  is a   Test and  has eight       words"
 
While str.IndexOf("  ") > 0 ' NOTE: Two spaces in the IndexOf operator
   str = str.Replace("  ", " ") ' NOTE: < That is TWO SPACES on the left side of the Replace
End While
 
Dim strArray As String() = str.Split(" ")
Dim WordCount As Integer = strArray.Length

Just an idea - even 'unacceptable solutions' help me to think outside of the proverbial box and come up with interesting solutions

Thanks for letting me play!

Ned

NedFrankly 0 Light Poster

Flexibility is the key, and an eagerness to learn summat knew.

Amen, my brethren. Younger programmers and folks who are new to posting in Tech forums, please take note of this thread.

This is how professionals agree to disagree, find common ground, and grow in our craft. This was and is a debate, a healthy exchange of ideas and concepts. No one got flamed, although you can tell that our passion for our work can easily lead to heated emotions. We managed to steer clear of that and in the end came out with a deeper respect for our various disciplines. That is what it's all about.

Thanks for having me!

Ned

NedFrankly 0 Light Poster

yes, of course you'll have to make an odbc connection and in your vb.net project you have to download the odbc reference.

Regards,
Guimas_Boy

Guimas provides the method IF you want to use ODBC. The original question was whether or ODBC is required. See my post two above this one - the code I provided is the sum total of what's required to connect without creating an ODBC connection.

Thanks!

Ned

NedFrankly 0 Light Poster

i think i still have a problem, can you show me how to do it using console application (vb.net)?

Once you have the string from your console in a variable, you can pretty much use the code I provided as written. Provide what code you've got, along with a description of the problem you face and we'll see what needs to be done next.

Ned

NedFrankly 0 Light Poster

Thanks for your response, SOS. Good debate, more common ground than appeared evident at first!

I guess the only thing that still bothers me is the concept that systems development is more challenging that application development. It's different parts of the same horse, but I can certainly trade stories of complexity and sheer technical prowess over an impossible problem with the best Sys Prog. Again, not better, just different. Complex system architecture, integration with unknown or legacy systems without clear definition or control over interfaces, data-mining poorly designed databases... All of this may seem to require less skill than you possess. I did not 'step down' from the challenges of low level programming. Indeed, I feel that my experiences at every tier allow me to bring formidable capability to my applications team. Sometimes even Sys Progs make our jobs difficult by not considering what the implications of technical decisions made at the OS or compiler level may have on our ability to effectively build applications on that framework.

I do want you to understand that telling new programmers that applications development is not challenging is a slanted view, based upon your hard won knowledge of systems programming. To those of us who prefer applications development, Systems programming is not much fun at all. Again, not better, not worse, just different. Good thing such diversity exists among programmers, right? I do a better job at my craft when you do a good job at yours, and hopefully my creative …

NedFrankly 0 Light Poster

This is manually constructed through the properties for the control...

Check out ListView and ListViewItem.
1. The ListView is the main container
1. ListViews contain ListViewItems. These are your rows.
2. ListViewItems contain SubItems. These are your columns.

Look in the microsoft generated code in your module. You'll see where the items and subitems are created (you may have to drill around for them if you're on 2005 - I'm on 2003 for a little while longer). Use intellisense to find out what else you can do (like ListViewItem.SubItem(i) Updates, Deletes, Adds, etc. ) Once you can target a single ListViewItem, and then reveal its subitems, you can update that row.

Hope that gets you started - let us see what you come up with!

Ned

NedFrankly 0 Light Poster

Here's how I do this (and we all have to do this alot)

strText = "My Text To Count Words"  ' (LTRIMmed and RTRIMmed)
dim aryWords() as string = strText.split(" ")
dim WordCount = aryWords.length + 1 ' Arrays are zero based.

What we just did was to create an array split by Spaces (" "). The number of elements in the array is the number of words in your sentence. This is similar in concept to feeding a Comma Seperated Value table to Excel. In our case, the comma is a Space. We don't generally care about puntuation, but a hanging period (with a space before it) or a hanging comma (spaces before and after) with throw our count off. To be sure you could convert all puntuation to empty spaces ("") with a replace or a REGEX prior to the strText.split(" ") Hope that helps!

NedFrankly 0 Light Poster

(Disclaimer: Just my 2 cents)
Yeah thats the main problem with these MS guys, they just do whatever makes them $$$$.

But then again it depends on how you see things, many people regard MS as god and will follow whatever put in front of them, so they just go with the Drag-and-drop-and-live-happily-ever-after thing.

Many people like to take things in their own hands and like to develop and contribute to the community than working on some proprietory format and waiting for the MS guys to further optimize the amount of effort required in dragging and dropping the components. ( its much more challenging making VB than making softwares in VB, i hope you catch the drift )

But still take your own pick and enjoy programming.

Wow. Quite a few slams and assumptions there... I know, your 2 cents. Please tolerate mine as well.

1.

Whatever makes them $$$$.

Hmmm. So you're in this for the love of it? Money's not an issue in your life, at least at this time. Student? Independently wealthy? At 43, I'm doing what I decided I'd do at the age of 15. I started programming then (in Basic on a Wang 2000) and I've done it ever since. I found that I can do what I love for free, which I did for awhile, or I can get paid for it so my family can have a good life and make a contribution to society. You're in it for the money …

NedFrankly 0 Light Poster

Well, the Systems Engineer path may NOT be the way to go for someone dedicated to Programming. From knowledge of job posting info (and the standard job description for Systems Engineer), you don't do much coding in the job.

In small shops, the architect generally codes (I'm one of the architects for my group of 6 programmers, and I definitely code) and the job is filled by a Software Engineer, typically senior staff, with some architecture knowledge. It's a complex discipline, and not one that is natural to me, but then I'm a Software Engineer, and now that I've stuck around long enough to be senior, I find that I have to architect and model as well as code. I am not a Systems Engineer, but our shop is not big enough to warrant a full time Architect, so we have to get by on the skills we have within our developers. Developers are not, typically, the best architects (we're prejudiced toward the code, so we have to consciously try to ignore the programming and think structure).

Some companies may call their Software Engineers 'Systems Engineers' or other titles. I know this, because in my company's profile, I'm a Systems Engineer, for the simple reason that the HR system didn't have 'Software Engineer' when our department was created a few years back, and it's never been corrected. We're working on it. You may have experienced a similar 'mis-naming' along the way, but don't let that lead you astray …

NedFrankly 0 Light Poster

Ah, GUI coding. I'd almost say that you took a similar path to mine. I was a senior everything late in my mainframe days, so when I got to program I typically got to work on the fun stuff (for me, the backend code). I was thrown into .net land by a calculated job move specifically designed to force me to learn .net, and I found myself doing... GUI's.

While many brilliant programmers stay on GUI their entire career, Presentation Layer coding is typically reserved to junior staff. I know, there are some really complex GUI's out there (and I've written quite a few), but to get to some really hardcore programming, you have to push for business layer coding. How to get there? Code some really bad-a$$ GUI's, blow their socks off, and dig in to the meat of the framework as much as you can get away with. If the business layer code is available to you (in many shops it's not) then get a copy of it and tear it apart. Don't get yourself in trouble here - many shops have rules against removing code from the building (or even viewing it if you're not at the right 'level'), so be up front about what you're doing. Your employer will recognize your ambition (if they have a clue) and support it.

I look forward to trading theories with you - this is how I learn.

Ned

NedFrankly 0 Light Poster

Indeed, it does. Here's where hard-won philosophy of programming comes in (I don't know your experience, but I've been at this most of my life). The most efficient answer is not always the best. In this case, it's preferable that the code be clear and concise (once the programmer understands the concept, and I got the impression that the original question may have been asked by a fairly new programmer). The trade-off is between having to walk the string character by character and compare each one (costly in and of itself) or have the system return the same results without iterating.

You'll find if you read anything I've posted here or on the web that I really get into 'different' algorythms to solve standard problems. I typically know the direction most programmers take given a standard problem like this one (because that's the first direction that comes to my mind as well), so I take that information and try to find a more elegant solution. It's a hobby of mine, and my 'weird' solutions have at time improved program performance by 10 or 100 fold. It's a good hobby, but I do admit that sometimes my elegant solution is not scalable, or is nice in theory but doesn't cut it in the real world. That's ok, if it gets me (and other programmers) to think in different ways then we've all learned something.

Thanks!

Ned

NedFrankly 0 Light Poster

Thanks - I work in corporate America (meaning that I don't get to pick my tools as often as I'd like :)

We use VS2003 (not quite ready to go 2005 yet, but it's in the works). I'm one of those annoying old programmers who can actually code most anything in VI, PICO, or Notepad, but I learned long ago that a good IDE is much better in the end than the bragging rights 'hard core' programming provides.

I enjoy great tools (Visual Studio is not bad, but I'm always looking for better toys) so if you have any recommendations I'm all ears.

Thanks for the welcome!

Jay aka Ned

NedFrankly 0 Light Poster

We don't care about the number of "",s we care about the difference between the old length (with the vowels intact) and the new length (with one of the vowels converted to ""). Example:

Text = "I am here"
Length of original Text = 9
Text after Replace("a","") = "I m here"
Length of new Text = 8
Difference = 1, therefore Count of A's in the text = 1.

We can ignore leading and trailing blanks because we are not counting any characters - we're replacing all occurances of one character with a no-space and getting the difference in lengths.

NedFrankly 0 Light Poster

How about this (if your strings are relatively short):

To get a count of each vowel without 'walking the string':

' strMyText is the string returned from the console
 
dim strMyTextCaps = strMyText.toUpper()  'We don't care about case
dim intTextLen = strMyText.length ' So we don't reevaluate every time
 
dim intCountA = intTextLen - (strMyTextCaps.Replace("A","").length)
dim intCountE = intTextLen - (strMyTextCaps.Replace("E","").length)
' etc...

It should be fairly obvious, but what we're doing is getting the length of the original string, and then replacing each vowel with an empty string. We subtract the new length from the original length and know the number of characters replaced. This is the vowel count for that vowel.

Haven't benchmarked for performance (nor have I run this - I believe the syntax is correct). A single line for each vowel is easier to read than a bunch of loops. Performance should not be a problem anyway, if the text is provided via the console.

Happy Coding!

Ned

NedFrankly 0 Light Poster

Hi, Y'all. My name's not Ned Frankly. It's Jay. Ned's a nom-de-web that I've used for about 10 years now, and he shows no signs of giving up :) .

So... I'm in my mid forties, I've been a programmer in one language or another since I was 15 (yup, in the 70's). I'm currently a Sr. Software Engineer, working primarily in VB.net and C#.net with a little 'whatever is needed' thrown in.

It's not enough to be a one-language-pony anymore - we have to be flexible and tolerant. No language is better than another when taken out of context. Tell me the job you want done, I'll tell you the language I'd use.

Nice forum, and I enjoy helping new programmers work through the complexities of .net. If you're new to .net, keep one thing in mind - it's probably NOT as difficult as you think it is.

Thanks for having me!

(Oh, and I really am ordained. Ned just uses the title Rev. more often than I do).

Jay aka Ned Frankly

NedFrankly 0 Light Poster

I'm sure this could probably be accomplished by using a metric poo-ton of If/Then/Else statements, but I would be willing to bet there would be a much cleaner way of doing this. Suggestions?

HashTables. Custom made for this process, but they won't scale well (really depends on the amount of memory in the machine). They are a 1 to 1 lookup, as in the dictionary you describe.

Database (such as Access). Create a two column table, populate with your translations, then query as: Select SpanishWord from DictionaryTable where EnglishWord = 'FooBar'; XML Files. Properly used, these are basically little databases on disk, easily read, easily loaded into a HashTable, a Datatable, or almost any other structure that typically 'catches' the data from a database call. Not as fast as Access, but great for small tables.

Hope that points you in the right direction! Happy coding!

Ned

NedFrankly 0 Light Poster

Let's see. I'd say Forth, but that would date me. It became Prologue after awhile, and is still one of the best 4GL's ever written. 6582 Assembler was fun, too (especially on a Commodore 64, which technically had a 6510 processor - the Commodore Disk drives had a 6502, as did the Apple II if I recall).

In the 80's, it was SAS versus COBOL in quite a few shops (this is big iron, water cooled processing, y'all. Your XBOX 360 has more computing power). Those of us who became SAS heavies had little respect for our long-in-the-tooth COBOL Colleagues. We were hip, and they, well, they coded COBOL.

Guess what happened to us hip SAS Wonks in the 90's? Well, new COBOL programmers were decidedly NOT on the way, as bright, shiny new Computer Science degrees were being put to use to build the World Wide Interweb thing... If they wanted to eat, many happy SAS progs took... (drum roll) COBOL gigs. It's OK, at least we now had nice PC's to run our 3270 emulators on... We didn't want to, but many of us took gigs fixing Y2K problems.

Side Note: You don't have to believe that the Y2K problem existed. Those of us who had to fix the problems KNOW that we had to fix many an algorithm that would fall flat when the calendar ticked over to '00'.

1999. The world came to an end. So many programmers on the market, no …

NedFrankly 0 Light Poster

Need a little more info...

Is this a bound listview (did you give it a datasource and bind it in the code behind) or is it manually constructed, either through code or through the properties for the control?

NedFrankly 0 Light Poster

Wayne's technique is about the only way you're going to pull this off if you're using 'real' windows.

If you've noticed in many games which 'take over your screen', the developers actually recreate Notepad within the game if text editing is required - everything 'Windows' in a well formed Full Screen game has to be reverse engineered and recreated within the full screen environment.

Even with Wayne's idea, if your app takes over resolution as well (as many games do) then the switch back to Windows mode is going to look, well, weird. You've probably alt-tabbed out of a game at some point and seen humongous icons on your desktop - that's the effect.

Try the suggestion, but consider how you might improve upon it by creating your own Virtual Notepad which works within your game.

Happy coding!

Ned

NedFrankly 0 Light Poster

Hi friends....


how to connect MS.Acess database into vb.net......

is any ODBC setting needed?

You can connect through oleDB (no ODBC required):

Dim SelectText as String = "Select * from myTable"
 
Dim SqlConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\asp_examples1\test.mdb
 
Dim myDA As oledb.oledbDataAdapter= New oledb.oledbDataAdapter(SelectText, SqlConn)

Ned