Papa_Don 31 Posting Pro in Training

Hi group,

After reviewing notes, I think I understand how to write the code to save data in the SQL Server. With that said, I want to understand the best way to arrange the data and upload it.

My project is creating an order. I'll have the usual part number, quantity ordered, price, extended price, etc. to save from each line. My question is, when I'm ready to save the line through code, do I think of what I'm saving as a line? That is, with each line I need to fill the "cells" of each column with ALL data, even that of the "static" information (order number, customer name, etc.)? In other words, should the "line" of the database look like this"

Order Number | Customer Name | Part Number | Quantity | U/M |
    321456   | Don Wilson    | AO2544SP    |  52      | SF  |
    321456   | Don Wilson    | AO2566SP    | 150      | SF  |

The "static" info I'm referring to are things like the Order Number and Customer Name. However things like Part Number, Quantity and Unit of Measure are the "variable" that will change from line to line. Keep in mind I'm asking this question as I'm sure at some point I'll want to create reports to show this info.

Hopefully I'm making sense here.

In advance, thanks for the help.

Don

Papa_Don 31 Posting Pro in Training

OK. I was able to copy and paste into the object explorer. Thanks for the help.

Papa_Don 31 Posting Pro in Training

Since I've never used SQL Management Studio, here's where I'm at:

From the Window's start button, I chose SQL Server 2008. Then I chose SQLServer Management Studio. The "Connect to Server" box comes up. There 3 drop down boxes that appear: Server Type (Database Engine), Server Name (Local, Browse for more, and Don-PC/SQLEXPRESS) and Authentication (Windows Authentication). I'm stuck here. I'm not sure what to chose. I've tried all the choices but I can't seem to find the right way to get to Database Settings.

I have found the path of the database I'm looking for a different way. But getting to the "server instance" is still foreign to me. I hate to have you hold my hand, but I need you to.

Don

Papa_Don 31 Posting Pro in Training

Group,

I may have messed up bad. I need help.

I was having trouble loading a database I had created with data. So I downloaded SQL Server 2008 Express that included the management tools. I tried to find and open the created database and never could find it using the management tools. So I then opended Visual Studio 2010 and tried to access the database there. I'm getting an error message that says, "Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed". Would someone know what has happened and how to fix it? I've put a tremendous amount of work into this and I don't want to loose this.

In advance, thanks for your help.

Don

Papa_Don 31 Posting Pro in Training

Group,

Via Visual Studio 2010, I've created a SQL Server database with the appropriate fields, data types, etc. I'm now ready to begin some testing, however I need to put some information in those datafields. I'm having trouble doing this.

I DID NOT set the tables to display in the DataGridView. I did a manual setup so that I could arrange the textboxes as needed. By this I mean that I displayed the Data Source and drug the fields onto the form one at a time. In doing so, VS2010 added the following code:

 Private Sub InventoryMasterBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InventoryMasterBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.InventoryMasterBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.BusinessBasicsDataSet)

In "Debug" mode, I've tried to enter the first bits of data (this will be inventory). As required, I pressed the "plus" button at the top of the form to start the first record. I entered the needed data and hit the "save" button at the top. Nothing seemed to happen. I tried pressing the plus key again to add a second part. It wouldn't allow it.

What did I do wrong? To begin testing my program, I've got to have a handful of part records to work with.

Help!!

In advance, thanks for the assistance.

Don

Papa_Don 31 Posting Pro in Training

Oxiegen,

Call off the dogs. I added "AddHandler txbUM.KeyDown, AddressOf txbUM_KeyDown" to the click event that creates the new panel. It worked and did what I needed it to do.

Thanks for the idea!

Don

Papa_Don 31 Posting Pro in Training

Oxiegen,

The problem with this is that I don't know how many new panels will be created by the end user. It could be 1 or 10 or 50. Learning how to do this will solves some other problems for me as well. Help!!

Papa_Don 31 Posting Pro in Training

Group,

I have a form that opens with a panel and multiple textboxes displayed that I created via the GUI. Once the user enters the desired information within this panel, a button is click and a new panel appears with the same textboxes displayed as the original. This panel and all of it's textboxes were created via code. As with the original, a button is clicked and another panel appears (identical to the first two). This third panel is created via the same code as the second.

Now the challenge: The original panel has one textbox that has a Sub FuncKeysModule attached to it that allows the user to use the function Key F1 perform a routine. The code looks like this:

Public Sub txbUM_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txbUM.KeyDown
        If e.KeyValue = Keys.F1 Then
            FuncKeysModule(e.KeyValue)
            e.Handled = True
        End If
    End Sub

    Public Sub FuncKeysModule(ByVal value As Keys)
        'Check what function key is in a pressed state, and then perform the corresponding action.
        Select Case value
            Case Keys.F1
                'Add the code for the function key F1 here.
                MessageBox.Show("F1 pressed")
        End Select

    End Sub

The specific textbox is called "txbUM". On the original panel, the F1 key works as it was designed. However when the subsequent panels are created via code, the function key no longer works, even though the textbox name is still "txbUM". The only difference is that this textbox is now within a different panel with a different name.

The question: …

Papa_Don 31 Posting Pro in Training

Excellent post!! Is this above routine something I can put in and test? If so, what controls do I need to add to "form1" to use it? I'm asking this as I'm a "learn by doing" person. I might even try to build this in parts and watch it behave as I test it. Writing the code and watching it work facinates me!!

As I said in an earlier post, this nothing like "old BASIC", and I'm glad. The idea of writing code for every sequence of every event would make for a long program. I'm really liking Visual Basic! Which prompts me to ask..... Is VB still being used alot as a program language? A friend of mine has encouraged me to learn Java (I know absolutely nothing about it).

For the record, I'm a "late in life learner". I was an operations exec in a family-owned Ceramic Tile and Stone company here in Atlanta for 26 years. The mortgage meltdown trimed that company down by almost two-thirds. I've been out of work now for 19 months. While I was there, the software package we used had a report generator in call "IQ", or as the software supplier called it "PRISMWRITER". It used a language very similar to the "old BASIC" (that I taught myself when Radio Shack began to market their "TRS-80" back in the early 1980s). Writing those reports required me to learn KornShell scripting as our program sat on a UNIX box. With the down time …

Papa_Don 31 Posting Pro in Training

Gentlemen,

Call off the wolves... Via your teaching, I found the fix!

Dim txtTmp As TextBox
        Dim strLine As String
        Dim pnlPartsSetup As New Panel
        Me.Controls.Add(pnlPartsSetup)
        Using reader As StreamReader = New StreamReader("c:\BusinessBasics\miscspareflds.txt")
            For intIndex As Integer = 1 To 36
                txtTmp = Me.pnlPartsSetup.Controls("txbLabel" & intIndex)
                strLine = reader.ReadLine
                txtTmp.Text = strLine
            Next
        End Using

It works perfectly!! I've tested it multiple times with multiple changes in the .txt file. It works!

May I refer to each of you as "Sensay"? LOL!

Guys, you rock.... Thanks!!

Don

Papa_Don 31 Posting Pro in Training

Wow..... In one sense, I'm glad I have had these problems. This has been a great learning issue. On the other hand, it has me realizing I have so much more to learn!! Thanks for sharing your knowledge and using it to teach!

I'll try to address everyone's thoughts, ideas and suggestions here:

TnTinMN,

All you need to do is create an instance of it and tell it which controls to manage and then issue it the commands for saving and loading the text at the proper point in your code.

I hate to admit this, but the term "create an instance" isn't clear to me. I understand managing the controls (i.e "txbLabel1.Text = "Insert Name Here"). Help me understand what an "Instance" is.

You also mentioned "Parents" and "Childs", both of which I've been introduced to. However my classes taught me about Parent and Child forms and not Parent and Child controls. But I'm thinking that we've did some of this back when I was trying to create a panel and it's controls within another panel when I was creating my Order Entry form. Last night I did go back and try adding a command to create this. My thought was to enter, "Me.Controls.Add(pnlPrtsPanelSetup)", hoping that doing this would allow the form to recognize the controls within the panel and allow the loop to generate the names of the TextBoxes and insert the names. It didn't work.

You mentioning "dragging" the TextBox design from the tool mention onto the …

Papa_Don 31 Posting Pro in Training

Rev. Jim,

Please forgive my syntax use. But it does seem to me that for some reason, these TextBoxes aren't being recognized in some way. In the code view, you can begin to type in "txbLabel...." and these names show up in the drop down box. So the next question is, does the "Me.Controls("txbLabel" & intIndex)" make some change that makes it appear that "txbLabel1" is not there?

To clarify, these TextBoxes were installed via the GUI and not at run time. The only "different" thing I've done is a) the panel has the labels and TextBoxes that I drug from the Data Source to create the form. As well, I deleted the original 36 labels from these user defined fields and replaced them with the new TextBoxes to be used as labels. I did this because the original plan was to replace the Label.Text with the information from miscsprflds.txt.

I hope this helps.

Don

Papa_Don 31 Posting Pro in Training

Rev. Jim,

I've created a form (frmInvSpareFldsSetup) that will give the end user to define 36 alpha and numeric fields to store data that will be useful primarily to them. These fields need to have a title for their reference. This form will allow them to name those 36 fields as they wish. Their names are now stored in a .txt file I've called "miscsprflds.txt". All of the writing and reading of this form from and to the text file works fine.

The second form (frmInventorPrtsSetup) will allow the user to setup their part records for the individual part numbers they require. On this form are those 36 user defined fields. Instead of using labels, I've formated 36 Textboxes to look like a label (I did this to see if my StreamReader problem was related to the labels). Because the Inventory database has a fair number of fields (I manually designed the form instead of using "DataGridView") I was required to put all of these fields within a PANEL to allow for a vertical scroll bar. I believe this is where the problem is. I suspect that the form doesn't "see" the TextBox names because it is embedded on the panel. Thus the error that I'm getting.

I hope this helps.

Don

Papa_Don 31 Posting Pro in Training

TnTinMN,

Your code gave me the error. It tells me that the TextBox I'm looking for isn't on the form. And that is partially true. The TextBox is on the form, however it is within a Panel that I'm using because it needs a vertical scroll bar. This suggests that I may need some other code for it to recognize the TextBox within the panel that IS on the form!! What tangled webs I weave!

Assuming my thought process is correct, what will allow the form to recognize the panel? Something tells me I'm going to have to create a "AddHandler" sub-routine and run these commands within that. I'm I starting to think correctly here?

Don

Papa_Don 31 Posting Pro in Training

tinstaafl, Yes. I tried it with and without the quotes. Same result. This is something of a challenge! The interesting thing is that it works on a different form perfectly. However that other form is not linked to a database. I'll ask again.... Could that be the cause?

Don

Papa_Don 31 Posting Pro in Training

Group, after writing the debug code, I got the following message: "A first chance exception of type 'System.NullReferenceException' occurred in Business Basics.exe". I did not get any "intValue" as an output. I did write the line as "Debug.WriteLine(intIndex)". If it should mean anything, the statement "txtTemp.Text = strLine" (the italisized) is highlighted.

I have inserted "Option Explicit" at the top of the form. VS2010 finished it as "Option Explicit on Imports System.IO". I trust that was correct.

You've written "As a first pass at debugging, I would set a breakpoint at the first executable line of the function". I'm not sure what you mean by this or how to do it.

Thanks for the reminder on "Debug". I had forgotten that I did that frequently when taking my courses.

Thanks for the input, guys!

Don

Papa_Don 31 Posting Pro in Training

Group,

The SQL Server (I'm using the edition that comes with Visual Studio 2010 Express) is different in every aspect form the database(s) that existed in the UNIX based program I work with over the last 15 years. There is much to learn and understand. With that said, I've connected to those databases using EXCEL and have had to link several tables to garner the information that I need. I have created 2 of the many tables I'm going to need for a Sales and Inventory program I'm trying to build. I know that these two table will need to be linked via "keys".

My questions are:

1) Can you create multiple keys within a database table? If so, how is this done? It is my belief that I will need these multiple keys to allow 1 database to link with several different databases.
2) When creating these keys, how is it you decide which is is to be "Primary"?
3) When setting up the "column" for the key, what "Data Type" is used?
4) Are these keys meant to hold data? If so, what kind of data?

Forgive my ignorance on this subject. In the classes I've taken on Visual Basic, we did touch on databases but didn't spend anywhere near enough time on the details. More specifically, we didn't discuss how to setup database tables. I really am a "newbie" but I'm really enjoying the learning. I've garnered so much information for this forum and …

Papa_Don 31 Posting Pro in Training

Rev. Jim/Nutster,

I've confirmed that I have 36 lines within the file "c:\BusinessBasics\miscspareflds.txt" as well as 36 Textboxes that I am trying to fill. I have also confirmed that I have created "txbLabel1" through "txbLabel36" and that all are properly named. I'm not sure how to find the value of "intIndex". I've done this before, but it escapes me right now as to how to do it.

To clarify your earlier question about "this page is linked to a database file", I chose not to use "DataGridView" in displaying the data within the database. I chose to design the view using the drag and drop method via the "Data Sources" list.

Nutster, in your earlier suggestion you wrote the following code:

Dim txtTmp As TextBox

Using reader As StreamReader = New StreamReader("c:\BusinessBasics\miscspareflds.txt")
    For intIndex As Integer = 1 To 36

        txtTmp = Me.Controls("txbUserFld" & intIndex)
        strLine = reader.ReadLine
        txtTmp.Text = strLine

    Next
End Using

In this the name "strLine" was not defined through a "Dim" statement as you did with "txtTmp". I've tried defining "strLine" as a string and changing the name "txbUserFld" to "txbLabel" in an effort to try to fix this. I get the same error. Is it possible that I am defining "strLine" wrong?

If you have some code to write that will send the number of "intIndex" to the Imediate box, please send it. I do want to look there to see if I can see what may be happening.

Thanks again guys. I …

Papa_Don 31 Posting Pro in Training

TnTinMN,

I certainly don't want to be a "cut and paste" programmer. I have really enjoyed every aspect of programming. It involves a general pattern of doing thing and lots of logic. The more I learn, the more I know I need to learn. For example, I've used "CType" multiple times. But I don't understand what it means or is trying to imply. I'm sure this is because I'm trying to equate my understanding of the "old" BASIC language with Visual Basic. It's clear there is little similarity.

I'll read the through the link you've suggested. Hopefully there are some examples and practice stuff to do. I learn much more by doing as opposed to just reading about it.

Thanks again. I greatly appreciate all of your help.

Don

Papa_Don 31 Posting Pro in Training

TnTinMN (and Rev. Jim),

I've not worked with RichTextBox(es) at all and therefore I don't know what they can do. So some of what you've said I know really understand. If you have the time, I would be interested in knowing what the various lines of code do. As I (hopefully) have stated before, I'm very new to Visual Basic (I've taken two courses at the local college in my area). Needless to say it went way to fast and we didn't cover everything indepth. However getting through these struggles have been a great teacher. My appreciation to you and Rev. Jim for helping me.

Thanks again.

Don

Papa_Don 31 Posting Pro in Training

Rev. Jim/Nutster,

I've changed my syntax to the following:

Private Sub InventoryPartSetup_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim txtTmp As TextBox
        Dim strLine As String
        Using reader As StreamReader = New StreamReader("c:\BusinessBasics\miscspareflds.txt")
            For intIndex As Integer = 1 To 36
                txtTmp = Me.Controls("txbLabel" & intIndex)
                strLine = reader.ReadLine
                txtTmp.Text = strLine
            Next
        End Using

    End Sub

     Private Sub InventoryMasterBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InventoryMasterBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.InventoryMasterBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.BusinessBasicsDataSet)



    End Sub

I'm now getting a error message that is pointed at the lines "strLine = reader.ReadLine" and "txtTmp.Text = strLine" when trying to run this. The message says, "NullReferenceException was Unhandled". It offers me a couple of choices to fix: "Use the new 'keyword' to create an object instance" and "Check to determine if the object is null before calling the method". Can you share where I'm going wrong here? Does it have to do with the fact that this page is linked to a database file?

Thanks again for the help.

Don

Papa_Don 31 Posting Pro in Training

Nutster,
Awesome! It worked as I planned. You make a good point regarding checking for the end of file. I'll write some logic in to set a default so it doesn't happen.

I did choose to use the following:

Using reader As StreamReader = New StreamReader("c:\BusinessBasics\miscspareflds.txt")
            For intIndex As Integer = 1 To 36
                Me.Controls("TextBox" & intIndex).Text = reader.ReadLine

Thanks again!

Don

Papa_Don 31 Posting Pro in Training

Group,

I have 36 string names that I'd like to create. In general these string names can be very similar. I thought I'd try creating a loop to do this for me. But I can seem to find the correct syntax to do this. To clarify, these string names can be as simple as

name1
name2
name3
and so forth and so on.

I tried doing the following:

For i As Integer = 1 To 36
Dim line As String = Me.ToString("line" & i)
Dim txt As TextBox = Me.Controls("txbUserFld" & i)
        Using reader As StreamReader = New StreamReader("c:\BusinessBasics\miscspareflds.txt")
        line = reader.ReadLine
End Using
txt.Text = line
Next

So you understand, StreamReader is reading a .txt file that has 36 names in it. I want to display these 36 names in 36 separate TextBoxes (TextBox1 thru TextBox36). To do this I need 36 separate string names (line1 thru line36). Obviously, I can write "Dim line1 As String" thru "Dim line36 As String" and "TextBox1.Text = line1" thru "TextBox36.Text = line36". But I've got to believe there is an easier way using a loop to do this.

Thoughts?

Thanks again!

Don

Papa_Don 31 Posting Pro in Training

Rev. Jim,

You're brilliant!! Thanks! You're the man!!

Don!

Papa_Don 31 Posting Pro in Training

tinstaafl,

Unfortunately, I'm not going to be able to move these into one multi-line TextBox.  I'm using this to allow the user to create 36 user-defind inventory fields.  To clarify, these will eventually populate the individual labels of those fields that will store part record data that the end-user will need.  For example, the actual field name in the database is "INV-MISC-COST-1".  The goal is to allow the user to name this field via the label of that field to clarify as to how it is being used.

I know there is a "ReadLine()" command. So I believe I should be able to move each line into an individual string and then to the Label1.Text.  But I first need to move these 36 user-defined names into the .txt file line by line.

Thoughts?

Thanks again,

Don

Papa_Don 31 Posting Pro in Training

Hi Group!

I need to write the data from multiple TextBoxes (which I've moved to individual string names) into one text file (miscflds.txt). These individual strings will need to be written one on top of the other. To be clear, it will need to look like this:

Item A
Item B
Item C
Item D
etc., so forth and so on.

Conversely, I will need to read the .txt file line by line and move each line to individual string names and then to their specific TextBoxes.

I've looked around on the net and I've not found good examples that I completely understand. Please know I'm working with Visual Basic (Visual Studio 2010 Express).

Could some of you suggest the codes required? I do understand that when writing I will be required to rewrite the entire file as I cannot overwrite a single line within the file.

Thanks again for the help.

Don

Papa_Don 31 Posting Pro in Training

Group,

To clarify, these files are meant to reside on the users server. I suppose this prompts another question: since I'm designing this to link to a SQL Server database, when the program is published and deployed, will the SQL Server also be installed as well?

Papa_Don 31 Posting Pro in Training

Group,

I have about 36 TextBoxes within one form in which I would like save the users entry. There will no need for this data to be save within a database as it will be used only one time. If it needs to be changed, I only want to overwrite the existing data. Therefore I'd prefer to save these as a text file (filename.txt), unless someone else has a better idea.

My question is: for these text files to be used when the program is published and deployed, where should I save these text files?

In advance, thanks for your help.

Don

Papa_Don 31 Posting Pro in Training

Rev Jim, TnTinMN

In the few minutes that I've take to look at your links, you make some valid points. I'll have to rethink my database design to ensure it's simple enough to do some reporting with. You should know that I worked a lot with a Unix driven database. My design is somewhat similar to it. However accessing the databases (and there were probably 30 or so different ones) for the purposes of reporting was actually very easy. And there were multiple ways of displaying the data. I generated hard paper reports for the owner whereas I prefered EXCEL based reports that I could put on my desktop. I was hoping this sql server would allow similar reporting options.

Thanks again for your input gentlemen!

Don

Papa_Don 31 Posting Pro in Training

TnTinMn,

I have thought this out very well! Every database field is important. I should share that some of these column heading will be used by other programs within the system to store information such as total sales dollars sold, total units sold, etc. However when manually entering a part number, there will be a lot of like data that will be stored in which I will enter a default value into the field at code level.

To further answer your question, one part number will have 170 "cells" of information within the one "row". Some of this will be blank at the time of creation because it will be filled later by other forms/programs/code.

I have written the following code. But I'm getting a "Object reference not set to an instance of an object" error. I've no idea what this means as I'm not getting any kind of error message at the time of the build.

Imports System.Data.SqlClient
Imports System.Configuration

Public Class frmInventoryMasterSetup

    Private Sub frmInventoryMasterSetup_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim tdate As String = Today.Date
        txbInvMasterTodaysDate.Text = tdate

    End Sub

    Private Sub btnInvMasterSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInvMasterSave.Click
        Dim loc1 As Integer
        loc1 = Integer.Parse(txbInvLocation.Text)
        Dim year1 As String = Today.Year
        Dim month1 As String = Today.Month
        Dim day1 As String = Today.Day
        Dim yyyymmdd As String = year1 & month1 & day1
        Dim indate As Integer = Integer.Parse(yyyymmdd)
        Dim objcon As SqlConnection
        Dim objcmd As SqlCommand

        Try …
Papa_Don 31 Posting Pro in Training

Hello Group!

I've created a fairly large database with approximately 170 columns. I now want to begin writing data to that database table and saving the data. I'm using a form I'm calling "frmInventoryMasterSetup". I've also created the individual textboxes that I want to link to the columns for saving. I now want to type data into the individual textboxes and have that information stored in the database.

To make your answer simple, lets use 3 of my fields. The sql database is called "DDdatabase.mdf". The table is called "InventoryMaster". I'm listing the textbox name and the database field name that I want to link together:

txbInvLocation connects to IN-LOCATION
txbInvPartNumber connects to IN-PART-NUMBER
txbInvDescription connects to IN-DESCRIPTION

What steps and code will I need to write to allow me to connect and write to this table?

I know some of you will want to ask why I didn't use "datagridview". I do want to use this form in some other ways and needed to format it this way to do it.

In advance, thanks for your assistance!

Don

Papa_Don 31 Posting Pro in Training

Gentlemen,

Given all great work you've given to help me, it has dawned on me that I now need to imbed the "line panel" within a larger "main panel" as I need to add a vertical scroll bar so that I can add as many lines as needed.

Using the same logic to create the original "line panel", I've added the following code in hopes that it would add the additional line panels into the "main panel". Here's what I've written:

' This set the order line panel within the main panel
        'Adding to main panel
        pnlMainPanel.Controls.Add(pnlOrderLine)
        pnlMainPanel.Visible = True
        'Adding to Form i.e. me
        Me.Controls.Add(pnlOrderLine)

It has failed. While the "panel" is created, it is behind the main panel. This makes me wonder if I need some kind of "AddHandler" or some other command to ensure these additional line panels are created within the main panel.

Do any of you have some thoughts or ideas? I've also added this question via another posting. You can read it at http://www.daniweb.com/software-development/vbnet/threads/448318/adding-multiple-panels-within-a-main-panel-via-code#post1937021 if you'd like to read or respond there.

Again, thanks for the help.

Don

Papa_Don 31 Posting Pro in Training

AleMonteiro,

I absolutely don't want to do an "exclusive database". I'm working with SQL Server that came with Visual Studio 2010. I'm thinking that's going to work fine. When I'm done, I'll put that database on a central server. I'll have the each computer on the VPN point to that server to save and retrieve data.

Thanks again for the help!

Don

Papa_Don 31 Posting Pro in Training

Lethugs,

You present a good idea. I'll definitely do this.

Don

Papa_Don 31 Posting Pro in Training

AleMonteiro,

Regarding changing databases, for the most part I completely agree. The last company I worked for did have the ability to change things like descriptions, etc. via a flat file. I did find that the individual doing it needed to have good knowledge on how to do thing correctly. Therefore database management was given to only myself and one other. But it did allow us to manipulate large amounts of data easily using a EXCEL spreadsheet. We'd then convert it to an CSV file and then use some propriatery software to actually update the database. I do want to be able to replicate that.

I'm sorry to say I don't know the term "exclusive database". Thinking how this program will be used, the database will be stored on a central server and the users will connect via a VPN. So I take it that the SQL Server or Oracle may be the way to go. Ease of interface will be extremly important as will the ability to handle and store a large number of records and connections.

I'll need to do some research on SQL Servers and Oracle to understand these better. As I stated, I'm new to programming and I'm doing so much of this learning on my own (although I've taken a basic and intermediate VB programming course at my local college).

Again, thanks for your input. I greatly appreciate this.

Don

Papa_Don 31 Posting Pro in Training

Hello Group!

I am writing my first complex VB2010 program that is a order entry and inventory management program. I know there are lots of these out there. However I'm attempting to write this for a specific type of business which creates its own set of challenges. However my question has only to do with storage and retrieval of all of this data that will be created. I am trying to accomplish a several things. So I would like your input on what products to use to store the data.

I do want

1) a product that will allow easy changes to some of these database fields using EXCEL (this product is easy to use and the masses seem to understand it)
2) I need to ensure that the individual "columns" of data can be made to accept changes made manually, whereas others need to be "locked" such that they can only be altered as a result of program (as an example, I want to allow manual changes to the description of a part number. However how many that are sold during a given month should only be altered by the program that controls order invoicing).

To get a better grasp of what I'm doing, please don't hesitate to ask questions. Ultimately I want to make this program simple to use by the end user.

In advance, thanks for your input.

Don

Papa_Don 31 Posting Pro in Training

Mr. Waddell,

I inserted the code you wrote and tested it. It continues to create the "pnlOrderLine" outside and behind the main panel (pnlMainPanel).

It's back to the drawing board.

Thanks again...

Don

Papa_Don 31 Posting Pro in Training

Group, you were very helpful to me in adding multiple textboxes, labels, etc., in my original post. If you would like to read through that, see http://www.daniweb.com/software-development/vbnet/threads/447985/creating-multiple-labels-textboxes-etc.-dynamically#post1934799.

In a similar vein, I now want to dynamically add these multiple panels within a "main" panel, one at a time, with the use of a button control.

I have created the first panel within the main panel on the form itself. Using the code the group and I developed in the original post (see the link above), I have the program generating the additional, identical forms. That code looks like this:

Private Sub btnCreateNewLine_(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateNewLine.Click

        Dim b As String = Short.Parse(a)

        'This creates the label "Part No."

        Dim lblPrtNo As New Label()
        lblPrtNo.Name = "lblPrtNo" & Convert.ToString(b)
        lblPrtNo.Text = "Part Number"
        lblPrtNo.ForeColor = Color.White
        lblPrtNo.Font = New Font("Sans Serif", 9)
        lblPrtNo.Font = New Font(lblPrtNo.Font, FontStyle.Regular)
        lblPrtNo.Location = New Point(13, 8)
        lblPrtNo.Size = New Size(77, 15)
        Me.Controls.Add(lblPrtNo)
        '
        'This generates the textbox for the user to enter the Part No.
        Dim txbPartNo As New TextBox()
        txbPartNo.Name = "txbPartNo" & Convert.ToString(b)
        txbPartNo.Text = ""
        txbPartNo.ForeColor = Color.Black
        txbPartNo.BackColor = Color.Yellow
        txbPartNo.Font = New Font("Sans Serif", 10)
        txbPartNo.Font = New Font(txbPartNo.Font, FontStyle.Bold)
        txbPartNo.Location = New Point(16, 26)
        txbPartNo.Size = New Size(263, 22)
        txbPartNo.Cursor = Cursors.Hand
        txbPartNo.AcceptsReturn = True
        txbPartNo.AcceptsTab = True
        txbPartNo.TabIndex = 10
        AddHandler txbPartNo.TextChanged, AddressOf txbPartNo_Textchanged
        Me.Controls.Add(txbPartNo)
        '
        ' This generates the button control to do a part number search
        Dim btnPartNoSearch …
Papa_Don 31 Posting Pro in Training

Group, please ignore this post. I figured it out. I think I was trying to make this much more difficult than it was.

Watch for the next post. It goes in line with my first post.

Thanks again.

Don

Papa_Don 31 Posting Pro in Training

Hello again, Group!

I'm creating a panel with multiple TextBoxes, labels, buttons, etc., within it. One of these buttons will end the entry of info and is intended to recreate the panel at a location further down the form. To this, I believe I need a loop. But this loop needs to needs to work one time and stop. Once that panel has its textboxes filled, the user will push a button to start the loop again, and create another panel further down the form.

Obviously "For...." and "Next" would handle the looping... assuming I wanted it to go on and on. So how do I tell it to work just the one time and then stop - but still hold the value so that, when the button is pushed again, the loop will start up again.

For the record, I'll have two loops that read:

Dim a As Integer
        For a = 0 To 1000
            Dim b As String
            b = Short.Parse(a)
            Dim x As Integer
            For x = 215 To 100000000 Step 147
            'insert additional steps here
            Next x
        Next a

Is it really a loop I want to use or is there another function or subroutine that I should use.

Thanks again group,

Don

Papa_Don 31 Posting Pro in Training

Rev. Jim,

For what it's worth, I was more interested in ensure that those textboxes that needed to be locked were locked. I wasn't concerned with the labels.

Again, thanks for your input and help. It has been extremely value. I've learned a lot!

Papa_Don 31 Posting Pro in Training

I like the "ReadOnly" property setting. I'll give that a whirl.

Thanks again!!

Papa_Don 31 Posting Pro in Training

Rev. Jim,

Removing "lblPrtNo.Enable = False" did the trick.

I think now the last question will be: How do I now lock those textboxes that need to be locked? Some of these will just hold data in them that will come from a database. Therefore these boxes are not meant to be changed or edited. Those like "txbPrtNo" will be changed and should be unlocked. This is where I thought "Enable = True or False" would be appropriate as I couldn't find another way of locking it. Thoughts here??

By the way... You guys are awesome..... Thanks so much for the help here!

Don

Papa_Don 31 Posting Pro in Training

tinstaafl,

I moved the Panel coding to the bottom and added the controls to the panel as suggested. It seems to work. Now the only issue to resolve is that of the back coloring and fore coloring of the controls themselves. These don't seem to work correctly. The labels have the correct background coloring but the letters are still black (they need to be white). Some of the TextBoxes need to be light yellow and these are white. Any thoughts there as to why these aren't being changed through the coding?

Thanks again for the help. If you can't tell, I'm a novice at this.

Don

Papa_Don 31 Posting Pro in Training

Rev. Jim,

I like the idea of "pnlOrderEntry.Controls.Add(lblPrtNo)". I've tried to use this to no avail. Here is what I've done:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim pnlOrderLine As New Panel()
        pnlOrderLine.Size = New Size(1445, 135)
        pnlOrderLine.Location = New Point(12, 53)
        pnlOrderLine.BorderStyle = BorderStyle.Fixed3D
        pnlOrderLine.ForeColor = Color.White
        pnlOrderLine.Visible = True
        Me.Controls.Add(pnlOrderLine)
        '
        'This creates the label "Part No."
        Dim lblPrtNo As New Label()
        lblPrtNo.Name = "lblPrtNo"
        lblPrtNo.Text = "Part Number"
        lblPrtNo.BackColor = Color.DarkBlue
        lblPrtNo.ForeColor = Color.White
        lblPrtNo.Font = New System.Drawing.Font("Sans Serif", 9)
        lblPrtNo.Font = New System.Drawing.Font(lblPrtNo.Font, FontStyle.Bold)
        lblPrtNo.Location = New Point(15, 56)
        lblPrtNo.Size = New Size(77, 15)
        lblPrtNo.Enabled = False
        lblPrtNo.Visible = True
        pnlOrderLine.Controls.Add(lblPrtNo)
        Me.Controls.Add(lblPrtNo)
        '
        'This generates the textbox for the user to enter the Part No.
        Dim txbPartNo As New TextBox()
        txbPartNo.Name = "txbPartNo"
        txbPartNo.Text = ""
        txbPartNo.ForeColor = Color.Black
        txbPartNo.BackColor = Color.LightYellow
        txbPartNo.Font = New System.Drawing.Font("Sans Serif", 10)
        txbPartNo.Font = New System.Drawing.Font(txbPartNo.Font, FontStyle.Bold)
        txbPartNo.Location = New Point(15, 72)
        txbPartNo.Size = New Size(263, 22)
        txbPartNo.Cursor = Cursors.Hand
        txbPartNo.AcceptsReturn = True
        txbPartNo.AcceptsTab = True
        txbPartNo.TabIndex = 10
        txbPartNo.Enabled = True
        txbPartNo.Visible = True
        AddHandler txbPartNo.TextChanged, AddressOf txbPartNo_Textchanged
        pnlOrderLine.Controls.Add(txbPartNo)
        Me.Controls.Add(txbPartNo)
    End Sub

    Private Sub txbPartNo_Textchanged(ByVal sender As System.Object, ByVal e As EventArgs)
        Dim txbPartNo As TextBox = DirectCast(sender, TextBox)
        Me.Text = txbPartNo.Name & ": " & txbPartNo.Text
        txbPartNo.Show()
    End Sub

Am I adding this line correctly as you've suggested? The label and TextBox are now hidden behind the panel. I need them inside/on top of the panel.

Thanks for your help.

Papa_Don 31 Posting Pro in Training

TnTinMN,

I made the changes you've suggested and I do see the Panel. Unfortunately though, the label and the TextBox are not inside the Panel and, if they were, they would be hidden (the Panel isn't transparent?). I have played around with the location settings to no avail.

This now prompts another question - should I build the Panel and the controls in the IDE and then "copy" and "paste" the Panel and it's controls below? If so, how do I do this?

Thanks again for the help.

Papa_Don 31 Posting Pro in Training

I should also add, I just tried adding the Panel. It is failing to run as well. Here is what I've written:

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.BackColor = Color.DarkBlue
        Me.ForeColor = Color.White
        '
        'This creates the Panel
        Dim pnlOrderEntry As Label = New Label
        pnlOrderEntry.Location = New Point(12, 48)
        pnlOrderEntry.Size = New Size(1232, 126)
        pnlOrderEntry.Visible = True
        Me.Controls.Add(pnlOrderEntry)

        '
        'This creates the label "Part No."
        Dim lblPrtNo As Label = New Label
        lblPrtNo.Name = "lblPrtNo"
        lblPrtNo.Text = "Part Number"
        lblPrtNo.BackColor = Color.DarkBlue
        lblPrtNo.ForeColor = Color.White
        lblPrtNo.Font = New System.Drawing.Font("Sans Serif", 9)
        lblPrtNo.Font = New System.Drawing.Font(lblPrtNo.Font, FontStyle.Regular)
        lblPrtNo.Location = New Point(15, 9)
        lblPrtNo.Size = New Size(77, 15)
        lblPrtNo.Enabled = False
        lblPrtNo.Visible = True
        Me.Controls.Add(lblPrtNo)
        '
        'This generates the textbox for the user to enter the Part No.
        Dim txbPartNo As TextBox = New TextBox
        txbPartNo.Name = "txbPartNo"
        txbPartNo.Text = ""
        txbPartNo.ForeColor = Color.Black
        txbPartNo.BackColor = Color.White
        txbPartNo.Font = New System.Drawing.Font("Sans Serif", 10)
        txbPartNo.Font = New System.Drawing.Font(txbPartNo.Font, FontStyle.Bold)
        txbPartNo.Location = New Point(15, 26)
        txbPartNo.Size = New Size(263, 22)
        txbPartNo.Cursor = Cursors.Hand
        txbPartNo.AcceptsReturn = True
        txbPartNo.AcceptsTab = True
        txbPartNo.TabIndex = 10
        txbPartNo.Enabled = True
        txbPartNo.Visible = True
        AddHandler txbPartNo.TextChanged, AddressOf txbPartNo_Textchanged
        Me.Controls.Add(txbPartNo)
    End Sub

    Private Sub txbPartNo_Textchanged(ByVal sender As System.Object, ByVal e As EventArgs)
        Dim txbPartNo As TextBox = DirectCast(sender, TextBox)
        Me.Text = txbPartNo.Name & ": " & txbPartNo.Text
        txbPartNo.Show()
    End Sub
End Class

To restate, the forecolor (white) in the label isn't being changed and the Panel is not …

Papa_Don 31 Posting Pro in Training

Rev. Jim and Tinstallfl,

In reviewing my original post, I see that I pasted lines 35-38 in error (these are not really there in my original programming).

Your suggestion of removing "txbPartNo.TextAlign = ContentAlignment.MiddleLeft" did allow the program to run.

But what is not working is the color changes within the label. It is currently black when I need it to be white as I'm actually using a Dark Blue background. Thoughts?

Papa_Don 31 Posting Pro in Training

I'm trying to create a form with multiple labels, textboxes and buttons within a panel. The user will fill in their data and click a button that will create a new identical panel with the same labels, textboxes and buttons.

I read through the following thread in an effort to begin understanding the process:
http://www.daniweb.com/software-development/vbnet/threads/423618/adding-multiple-textboxes-to-a-form-control-array

I've attempted to try using some of the same code to do as I wish to no avail. Here is what I've written:

Public Sub frmOrderEntry2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
    '
    'This creates the label "Part No."
    Dim lblPrtNo As Label = New Label
    lblPrtNo.Name = "lblPrtNo"
    lblPrtNo.Text = "Part Number"
    lblPrtNo.ForeColor = Color.White
    lblPrtNo.Font = New System.Drawing.Font("Sans Serif", 9)
    lblPrtNo.Font = New System.Drawing.Font(lblPrtNo.Font, FontStyle.Regular)
    lblPrtNo.Location = New Point(6, 8)
    lblPrtNo.Size = New Size(77, 15)
    lblPrtNo.TextAlign = ContentAlignment.MiddleLeft
    lblPrtNo.Enabled = False
    AddHandler lblPrtNo.TextChanged, AddressOf lblPrtNo_Textchanged
    Me.Controls.Add(lblPrtNo)
    '
    'This generates the textbox for the user to enter the Part No.
    Dim txbPartNo As TextBox = New TextBox
    txbPartNo.Name = "txbPartNo"
    txbPartNo.Text = ""
    txbPartNo.ForeColor = Color.Black
    txbPartNo.BackColor = Color.White
    txbPartNo.Font = New System.Drawing.Font("Sans Serif", 10)
    txbPartNo.Font = New System.Drawing.Font(txbPartNo.Font, FontStyle.Bold)
    txbPartNo.Location = New Point(6, 26)
    txbPartNo.Size = New Size(263, 22)
    txbPartNo.TextAlign = ContentAlignment.MiddleLeft
    txbPartNo.Cursor = Cursors.Hand
    txbPartNo.AcceptsReturn = True
    txbPartNo.AcceptsTab = True
    txbPartNo.TabIndex = 10
    txbPartNo.Enabled = True
    AddHandler txbPartNo.TextChanged, AddressOf txbPartNo_Textchanged
    Me.Controls.Add(txbPartNo)
     Private Sub lblPrtNo_Textchanged(ByVal sender As System.Object, ByVal e As EventArgs)
    Dim lblPrtNo As Label = DirectCast(sender, Label)
    Me.Text = lblPrtNo.Name & ": " & …
Papa_Don 31 Posting Pro in Training

I'm attempting to do similar things here, only with multiple labels, buttons and textboxes. I've attempted to insert the needed code to display these controls on the form. Unfortunately with I debug it, the form is still blank. Here is what I've written:

Public Sub frmOrderEntry2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load

    '
    'This creates the label "Part No."
    Dim lblPrtNo As Label = New Label
    lblPrtNo.Name = "lblPrtNo"
    lblPrtNo.Text = "Part Number"
    lblPrtNo.ForeColor = Color.White
    lblPrtNo.Font = New System.Drawing.Font("Sans Serif", 9)
    lblPrtNo.Font = New System.Drawing.Font(lblPrtNo.Font, FontStyle.Regular)
    lblPrtNo.Location = New Point(6, 8)
    lblPrtNo.Size = New Size(77, 15)
    lblPrtNo.TextAlign = ContentAlignment.MiddleLeft
    lblPrtNo.Enabled = False
    AddHandler lblPrtNo.TextChanged, AddressOf lblPrtNo_Textchanged
    Me.Controls.Add(lblPrtNo)
    '
    'This generates the textbox for the user to enter the Part No.
    Dim txbPartNo As TextBox = New TextBox
    txbPartNo.Name = "txbPartNo"
    txbPartNo.Text = ""
    txbPartNo.ForeColor = Color.Black
    txbPartNo.BackColor = Color.White
    txbPartNo.Font = New System.Drawing.Font("Sans Serif", 10)
    txbPartNo.Font = New System.Drawing.Font(txbPartNo.Font, FontStyle.Bold)
    txbPartNo.Location = New Point(6, 26)
    txbPartNo.Size = New Size(263, 22)
    txbPartNo.TextAlign = ContentAlignment.MiddleLeft
    txbPartNo.Cursor = Cursors.Hand
    txbPartNo.AcceptsReturn = True
    txbPartNo.AcceptsTab = True
    txbPartNo.TabIndex = 10
    txbPartNo.Enabled = True
    AddHandler txbPartNo.TextChanged, AddressOf txbPartNo_Textchanged
    Me.Controls.Add(txbPartNo)

     Private Sub lblPrtNo_Textchanged(ByVal sender As System.Object, ByVal e As EventArgs)
    Dim lblPrtNo As Label = DirectCast(sender, Label)
    Me.Text = lblPrtNo.Name & ": " & lblPrtNo.Text
    lblPrtNo.Show()

End Sub

Private Sub txbPartNo_Textchanged(ByVal sender As System.Object, ByVal e As EventArgs)
    Dim txbPartNo As TextBox = DirectCast(sender, TextBox)
    Me.Text = txbPartNo.Name & ": " & txbPartNo.Text
    txbPartNo.Show()
End Sub

Again, please be aware …