Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You could try

Private Sub TextBox1_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    TextBox2.AppendText(e.KeyChar)
End Sub

This would also allow you to filter out certain keys like backspace.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Isn't "<tag/>" shorthand for "<tag></tag>"? In which case the original code is malformed. It looks like double clicking the code is just replacing the shorthand with the longhand version.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

In that case it cannot be parsed by an algorithm. You have to have some absolute way of determining where the various components begin and end. You can't detect based on a digit because you may have a comoponent like 5th Ave. What about if we tokenize based on blanks? That way the above would parse out as

Main
Street
230
5

We could start at the first token and keep grabbing as long as the entire token is not numeric. The first all-numeric would be the house number and if there was another numeric following that it would be the apartment number. Would that work in all cases?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

When you say

For example
Streetname / house number / box number

You are not actually giving an example. Do you actually mean that the format is like

Main Street/1234/57

Without knowing what formats are valid I can't show you how to parse it. Typical addresses might be

5B-1017 Cornet St.
108 General Brock Dr.
Box 117 Mayberry

Parsing on blanks is not an option because the different fields can not be determined by blanks alone. Typically, a residence will also not have both a house number and a box number.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I've said this before - I'm not well versed in DataTables, DataAdapters, DataSets, etc but I think I can take a few educated guesses. You declare ds at the class level and you fill it in sReadDbf but in that sub you do

Dim ds As New DataSet

so the actual "ds" that you are using in sReadDbf is a copy local to that sub. try replacing

Dim ds As New DataSet

with

ds = New DataSet

That way you will be using the same "ds" in both subs and when you reference it in sWriteAccess it will retain all the properties from when you filled it in sReadDbf.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Once I understood how the voting worked I found it to be very easy. I'd rather see it stay the way it is than go to a popup.

WaltP commented: Me too. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I thought that the 'ds' was available when I declared it as a Public declaration at the top of my code

That may be true, however I can't see the top of your code that includes public declarations. All you posted were the two subs, one of which instantiates its own copy of ds and one that doesn't. And on the Public declaration did you just declare ds or declare it and create it as New?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You declare and create ds in Sub sReadDbf but you didn't declare or create it in Sub sWriteAccess

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Dim bill As integer=textbox14.text

You have to convert textbox14.text from string to integer. One way to do this is

If IsNumeric(textbox14.text) Then
    bill = textbox14.text
Else
    'textbox14.text is not a number
End If

As for the rest, I'll assume the error occurred on line 3 (you didn't specify) and that the error is because txtbillno is a textbox in which case the code should be

Form18.txtbillno.Text = Module1.billno
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

When a paramer is passed By Val then the sub/function gets a copy of the parameter.Any changes made inside the sub/function will not affect the original parameter. However, if you pass By Ref then any changes will affect the calling parameter. For example

Dim x As Integer = 5
MySub(x)
MsgBox(x)


Private Sub MySub(ByVal p As Integer)
    p += 1
End Sub

will display the value 5, but

Dim x As Integer = 5
MySub(x)
MsgBox(x)


Private Sub MySub(ByRef p As Integer)
    p += 1
End Sub

will display the value 6

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

A short version would be

Dim txt() As String = Filter(System.IO.File.ReadAllLines("d:\temp\test.txt"), "(Yes)")
TextBox1.Text = Join(txt, vbCrLf)

A shorter version is

TextBox1.Text = Join(Filter(System.IO.File.ReadAllLines("d:\temp\test.txt"), "(Yes)"), vbCrLf)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

It would help to know the specific error.

Perhaps a simple example that I have tested locally. I have a table named "users" defined as

    UserID      int
    UserName    varchar(50)
    UserType    varchar(50)

and a text file (bulk.txt) that contains (tab delimited)

    1    Jim     user
    2    George  admin
    3    Fred    admin
    4    Amy     user
    5    Ellen   user
    8    Joyce   user

To insert all of the records at once (assuming no duplicate key conflicts) I would execute the query

    BULK INSERT users FROM 'D:\temp\bulk.txt' WITH (FIELDTERMINATOR = '\t')

and the query would be created in code as

    qry = "BULK INSERT users                " & _
          "     FROM 'D:\temp\bulk.txt'     " & _
          "     WITH (FIELDTERMINATOR = '\t')"

One "gotcha" is that you must be a member of the sysadmin or bulkinsert group to execute a BULK INSERT.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Do you already have data in the table? Is the column of type int?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

What diafol said. Apparently some people can take a hint only if it is applied with a sledge-hammer.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

but when you come to know that he dont have any worth of you and even laugh when you show respect to them, then that is a pathetic situaion. what about this ?

I suppose you can conclude that the relationship is not what you had assumed and move on. Just because this other person is not interested in the same sort of relationship that you are doesn't mean that he/she considers you worthless.

when anyone is helpful to you alot(just like you , for example), you get attached to that person

Sometimes people just want to help without entering into a personal relationship. What you get out the relationship is help with a technical problem. What I get out of it is a feeling of satisfaction that my skills are being put to use and the good feeling that comes from helping others.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You should determine whether this is a perceived (by you) slight or an actual slight. If it is actual then you should ask yourself if it was dererved. Was it caused by a specific act or series of acts on your part? Was the person who slighted you the target of your unwanted attention? Are you fixated on this person in a creepy way, such as, perhaps, by adopting the same avatar? If this was a face=to-face relationship and you started dressing and acting like the other person this would be seriously weird.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Sorry. A little of the old syntax slipped in. Replace "From" with "=". That's the problem with being a dinosaur. Because your citation numbers are actually strings you will have to separate the "D" from the rest of the number in order to generate the new numbers. Look at this

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        Dim citStart As Integer = CInt(txtStart.Text.Substring(1))
        Dim citEnd As Integer = CInt(txtEnd.Text.Substring(1))
        Dim prefix As String = txtStart.Text.Substring(0, 1)

        For citnum As Integer = citStart To citEnd
            Dim newcit As String = prefix & citnum
            TextBox1.AppendText(newcit & vbCrLf)
        Next

    End Sub

txtStart.Text.Substring(1) throws away the first character (the "D") and keeps the remaining string (the number part). Cint takes the number portion and converts it to an integer. We do this for both the start and end strings. Then we save the leading character ("D") in prefix.

The loop then generates the series of numbers, slaps the "D" back on the start and pops it into a multiline textbox. Of course, you would just use newcit in a query to insert the new records

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If we have

Dim rnd As New Random

then we can generate a random number from 1 to 5 by

rnd.Next(1,6)

Don't ask why you have to specify 6 when you want a number from 1 to 5. That's just Microsoft's mindless idiocy at work. If you have previously set up

Private pics() As PictureBox = {PictureBox1,PictureBox2,PictureBox3, _
                                PictureBox4,PictureBox5}

then in your timer event you can do

Dim num As Integer = rnd.Next(0,5)
pics(num).Top += 5

'do something here if the picture is off the screen
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Funny thing, I have a brother-in-law who is in law enforcement. His name is also Robert Taylor.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

That depends on whether or not you adjust the Top property for an image. If you do then it falls. If you don't then it doesn't.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

That's because you are only affecting one PictureBox in the timer. If you have multiple pictureboxes you could either generate a random number and use that in a Select Case to pick a random image, or you could create an array of references to the pictureboxes and use the random number as an index into that array.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

It's easier to get the idea if you don't think in terms of computers. Imagine you are in charge of several officers and you are not the one handing out citations. You have a pad of forms. Each form has a table with blank rows and columns labeled Citation Number, Status and Date Issued. You tear off the first form and fill in only the Citation Number column with 25 numbers. You give that to the first officer. You fill out the next form in the same way with another block of 25 (different) numbers and give it to the second officer. You do this for all of your officers. Each officer now has an allocated block of numbers. When an officer has used up all of the numbers (or is running low), he/she comes to you for another sheet of numbers. Now replace "sheet" with "database". You don't have to record START and END numbers as two columns because they are already recorded in the first and last rows.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you don't have a default value set for status then you can set it in the insert as

Dim query As String = "INSERT INTO Citations (dui_cite_no,status) " & _
                      "VALUES(" & cit_no & "'FREE')"
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

How is the data getting into the DataGridView? Where does the data come from?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Sorry. The day kind of got away from me.

So your table would have (as a minimium)

*dui_cite_no    int
 status         varchar(16) (default value is 'FREE')

but possibly also including fields like

 alloc_date     datetime
 alloc_by       varchar(50)

Where "*" indicates a primary key field. I don't know the format of the numbers so I don't know if you would use an int or a some type of text field. The "allocated" field could be a boolean, or perhaps more useful, a datetime field so you could look at the table and determine when a particular number was allocated. perhaps you would also include a field to identify the officer.

To get the next available number your query would look like

SELECT TOP(1) dui_cite_no WHERE status = 'FREE'

and to prevent someone else from grabbing it you could immediately set the status to something like 'PENDING' and at that time enter an alloc_date and alloc_by (officer ID). Then when the citation is completed you could update the status to 'COMPLETED'. You could even allow the officer to save work in progress and keep the status as 'PENDING' until final submission at which point you change status to 'COMPLETED'

All you would need is a dialog box where you could enter the start and end range values of the next block. The code behind that would have a for loop like

For cit_no As Integer From Cint(txtStart.Text) to Cint(txtEnd.Text)
    Dim query As String = "INSERT INTO …
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Except your version does the opposite of what he wanted. He wants Enabled if the value is equal to 1.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You could also replace

If tabC.TabCount =1 Then
    EnableDisableMyControls(TRUE)
Else
    EnableDisableMyControls(FALSE)
End if

with

EnableDisableMyControls(tabC.Tabcount = 1)
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Oh. Well that makes sense. In that case you still need (minimum) the dui_cite_no and an allocation field. Then you would need a dialog box to prompt you for a new range of numbers to add when you run out and perhaps a warning for the app to tell you when you are running out of free numbers. I'll get back in a bit. Gotta go shopping.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Your database is going to have multiple records containing dui_cite_start, dui_cite_end. You want to keep track of which dui_cite numbers have been allocated. If your table looked like

dui_cite_no
allocated

where dui_cite_no was the primary key then you could get then next available number as

select top(1) dui_cite_no where allocated = 'Y'

If no record is returned then you are out of citatation numbers and have to add more. Like I asked before, if the only thing you are going to do when you run out is add more, why not just let the database generate the new numbers as needed?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'm confused as to the problem you are trying to solve. It seems to me that whenever someone starts to fill out a new DUI form, they should be issued the next available number. That's just a simple query to the database to allocate and assign the next available number. I don't understand why you need to be prompted to enter more numbers when you can just generate them.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Since you already know how to read and write from/to the database I assume you are wondering how to preserve the number last used by the app. Before I offer a suggestion, what version of VB are you using? Newer versions of VB use

My.Computer.Settings

to save settings between sessions on a per user or per application basis.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

My pleasure. Hope it works for you.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Yes, but you have to redirect the stdin and stdout (and stderr). I've attached a sample VB 2010 project that shows how to do it.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If by on the first setup you mean the first time it is run after setup, then yes. And just so you know, there is no rule that states the db/log files have to be stored in the same folder that SQL uses by default.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

One more note - I just found out that sp_attach_db has been deprecated. The recommended method to attach is shown by the following example

query = "CREATE DATABASE PUBS " & _
        "       ON(NAME='PUBS_Data',FILENAME='D:\SQL\DATA\Pubs.mdf') "     & _
        "   LOG ON(NAME='PUBS_Log' ,FILENAME='D:\SQL\DATA\Pubs_log.ldf') " & _
        "   FOR ATTACH WITH ENABLE_BROKER;"

set con = CreateObject("ADODB.Connection")
con.Open "Driver={SQL Server};Server=.\SQLEXPRESS;Trusted_Connection=yes;"
con.Execute query
con.Close
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You can execute it like any other query string. I usually use ADO. You can run a vbScript file or you can code it in your app (it could detect if the database is not attached and prompt the user for the location). The vbScript code is

DBNAME = "PUBS"
DBFILE = "D:\SQL\DATA\Pubs.mdf"
DBLOG  = "D:\SQL\DATA\Pubs_log.ldf"

set con = CreateObject("ADODB.Connection")
con.Open "Driver={SQL Server};Server=.\SQLEXPRESS;Trusted_Connection=yes;"
con.Execute "sp_attach_db 'PUBS','" & DBNAME & "','" & DBFILE & "','" & DBLOG & "'"
con.Close

and you will notice my slight oopsie on the earlier post (which I will correct). I didn't include the dbname parameter which should go first. This is the name that will appear in SQL server for your database.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Before you use the database you have to attach it. You can use the following command

sp_attach_db 'dbname','datafilename','logfilename'

If your database and log files are named D:\SQL\DATA\mydb.mdf and D:\SQL\LOG\mydb_log.ldf then your command looks like

sp_attach_db 'mydb','D:\SQL\DATA\mydb.mdf','D:\SQL\LOG\mydb_log.ldf'

You might want to truncate the log file before you move it off your machine.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You can send private messages on DaniWeb. When you click on a user's name, you go to their profile page. There is a "send private message" under CONTACT ME on that page. At the top of every page there is a link labeled "PRIVATE MESSAGES". If you have any unread messages it will be flagged there. We discourage asking for help in private messages because any help given there cannot be seen by anyone else. However, if you have to pass sensitive data this is one way to do it.

fRodzet commented: Ty +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Sorry. My mistake. Change the "or" to a comma and it works as in

Case  "Main-Hand + Shield", "Main-Hand + Source"
fRodzet commented: Ty +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Glad to help.

My code selects the next item in the list and wraps back to the beginning when it reaches the end of the list. If it is in a timer then it will cycle continuously. If there are three items in the list then SelectedIndex will cycle as 0, 1, 2, 0, 1, 2, ...

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
If ListBox1.SelectedIndex = ListBox1.Items.Count - 1 Then
    ListBox1.SelectedIndex = 0
Else
    ListBox1.SelectedIndex += 1
End If
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

By the way, you can also rewrite blocks such as

MainCombo.Items.Add("Spear")
MainCombo.Items.Add("Sword")
MainCombo.Items.Add("Mace")
MainCombo.Items.Add("Wand")
MainCombo.Items.Add("Dagger")
MainCombo.Items.Add("Axe")

as

MainCombo.Items.AddRange({"Spear","Sword","Mace","Wand","Dagger","Axe"})

and it's a matter of style but I prefer Select Case blocks to lengthy If-Then-ElseIf constructs. For example

Private Sub BuildCombo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BuildCombo.SelectedIndexChanged

    'Build Selection

    MainCombo.Items.Clear()
    OffCombo.Items.Clear()

    Select Case ClassCombo.Text

        Case "Wizard"

            Select Case BuildCombo.Text

                Case "Main-Hand + Shield" or "Main-Hand + Source"
                    Label5.Text = "Select Main-Hand" 
                    MainCombo.Items.AddRange({"Spear","Sword","Mace","Wand","Dagger","Axe"})

                Case "Two-Handed Weapon"
                    Label5.Text = "Select Two-Handed"
                    MainCombo.Items.AddRange({"Two-Handed Axe","Two-Handed Sword","Bow","Crossbow","Two-Handed Mace","Staff"})

            End Select

        Case "Barbarian"

            Select Case BuildCombo.text

                Case "Main-Hand + Shield"
                    Label5.Text = "Select Main-Hand"
                    OffCombo.Enabled = False
                    MainCombo.Items.AddRange({"Sword","Mighty Weapon","Axe","Dagger","Mace"

and so on. If you have code that is common to all blocks then move it out of the block.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Weapons is declared at the class level (outside of all subs/functions so it is accessible from from all subs/functions. The ClassCombo_SelectedIndexChanged event gets fired when the user selects a new item from the ClassCombo control. The code in that handler:

Dim cmb As ComboBox = sender
ComboBuild.Items.Clear()
ComboBuild.Items.AddRange(Weapons(cmb.Text))

first clears the ComboBuild (sorry about the name change) combobox, then adds all of the items from Weapons that are associated with that choice. For example, if the user selects "Wizard" then effectively what you get is

ComboBuild.Items.AddRange({"Main-Hand + Shield", "Main-Hand + Source", "Two-Handed Weapon"})

If the user selects Barbarian then the items from that entru in Weapons gets added to ComboBuild. It would be a simple matter to create a text file containing

Wizard,Main-Hand + Shield,Main-Hand + Source,Two-Handed Weapon
Barbarian,Main-Hand + Shield,Main-Hand + Off-Hand,Two-Handed Weapon
Monk,Main-Hand + Shield,Main-Hand + Off-Hand,Two-Handed Weapon
Witch Doctor,Main-Hand + Mojo,Main-Hand + Shield,Two-Handed Weapon
Demon Hunter,Main-Hand + Off-Hand,Main-Hand + Quiver,Two-Handed + Quiver,Main-Hand + Shield

Then build the Weapons dictionary by reading the file in at runtime.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

For a start I would set up tables or some other data structures instead of hardcoding the parameters. As I posted earlier, I would start by doing something like

Private Weapons As New Dictionary(Of String, String())

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

    'create lists of weapons for each character class

    Weapons.Add("Wizard", {"Main-Hand + Shield", "Main-Hand + Source", "Two-Handed Weapon"})
    Weapons.Add("Barbarian", {"Maiin-Hand + Shield", "Main-Hand + Off-Hand", "Two-Handed Weapon"})
    Weapons.Add("Monk", {"Main-Hand + Shield", "Main-Hand + Off-Hand", "Two-Handed Weapon"})
    Weapons.Add("Witch Doctor", {"Main-Hand + Mojo", "Main-Hand + Shield", "Two-Handed Weapon"})
    Weapons.Add("Demon Hunter", {"Main-Hand + Off-Hand", "Main-Hand + Quiver", "Two-Handed + Quiver", "Main-Hand + Shield"})

    'populate class combobox

    ClassCombo.Items.Clear()

    For Each key As String In Weapons.Keys
        ClassCombo.Items.Add(key)
    Next

End Sub

Private Sub ClassCombo_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ClassCombo.SelectedIndexChanged

    'populate the weapons combobox with weapons for the selected character class

    Dim cmb As ComboBox = sender
    ComboBuild.Items.Clear()
    ComboBuild.Items.AddRange(Weapons(cmb.Text))

End Sub

Except I would likely store the strings in a file and read it in at run time.

Note that you can add all of the array items in one statement using AddRange (I neglected to do that in the earlier example). As for the remaining logic, there are just too may combinations to work through. You'd have to try to set up the tables. I don't know the logic behind your assignments.

fRodzet commented: Damn TY! +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Because APSDPS.Text is a String and you can't use strings in numeric calculations. CDbl converts a string to a double (or raises an exception if the string cannot be converted). For example, you can't execute

x = 5.3 + "19.12"

but you can do

x = 5.3 + Cdbl("19.12")
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You have to convert it to a number before you use it in the calculation. Typically, this is done by first checking to see if the string CAN be converted to a number as in

If IsNumeric(APSDPS.Text) Then
    APSDPS3.text = (CDbl(APSDPS.Text) * (1.0 + 15.0/100.0)).ToString
fRodzet commented: Useful +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

What database are you using? MS SQL, Oracle, mySQL, Access, etc?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I don't know what method you are using to interface to the database but it could be done like

    Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

        Dim lbx As ListBox = sender

        Dim con As New SqlConnection
        Dim cmd As New SqlCommand
        Dim rdr As SqlDataReader

        Dim reportfile As String
        Dim reportflag As Boolean

        con.ConnectionString = "Data Source=.\SQLEXPRESS;Initial Catalog=myDB;Integrated Security=True"
        con.Open()

        cmd.Connection = con
        cmd.CommandText = "SELECT reportfile, reportflag FROM report " & _
                          " WHERE reportname = '" & lbx.Text & "'"

        rdr = cmd.ExecuteReader()

        If rdr.HasRows Then
            rdr.Read()
            reportfile = rdr.GetString(0)
            reportflag = rdr.GetBoolean(1)
        End If

        rdr.Close()
        con.Close()

    End Sub

You can add any code after line 24 to do what you want with reportfile and reportflag. You would also have to change the ConnectionString accordingly.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Oh. I thought you meant SAM as in ISAM (Indexed Sequential Access Method).

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Any chance you can post a sample file?