I couldn't open the Excel file. Apparently, it's not compatible with my version. There's no easy way to do what you want with a ListBox. It's much easier, and a lot less code, with a ListView. You can also programmatically adjust a ListView columns to fit the longest data in each column. I don't see the logic in using a ListBox, but I could be missing something.

I couldn't open the Excel file. Perhaps it's not compatible with my version. Trying to implement columns in a ListBox is much more complicated and requires a lot more code than using a ListView, if at all possible. Columns in a ListView can be programmatically set to the width of the contents with the Windows SendMessage function and the LVM_SETCOLUMNWIDTH parameter. A ListView would eliminate a large portion of your code, particularly that dealing with the memory arrays. A ListView also allows the user to set the column width as they desire, and can also be programmed to allow sorting rows based on a selected column.

Alternatively, you could use a DataGrid and an Access database to handle your record functions.

Here's version 5 with a ListView. All functions work - search, delete, add, etc. It seems to me to be a lot less code than your previous versions. I included code to automatically resize the columns based on the contents. I also included code to sort the rows based on a column. Click the column header to sort ascending, click again to sor descending. This about the best I can do with my understanding of what you're trying to accomplish. Best wishes.

well ,looks different now hahaha.
I think the version 2 or 3 works fine
but you mentioned about:
"When you install your app on another system, the .ocx will be installed along with your app."
how its possible? How you make the app as .exe ?
Normally I just go to: File > Make : Project.exe
but in this case it's not loading the .ocx file inside the .exe file, right?
how can i add .ocx file in app?
because my plan is to make the .exe file PORTABLE, just move the .exe file to any laptop and it will work. no installation or sort of things.

After you create your .EXE there are 3 ways you can use to create an installation file / package.

  1. The Package and Deployment Wizard that is part of VB6. It should be on your Start menu.
  2. Visual Studio Installer (my preferred method, though a bit more complicated). I don't recall where VSI came from - the MSDN Library or downloaded.
  3. A commercial package such as SamLogic (https://www.samlogic.net/visual-installer/visual-installer.htm) or Wise Installer.

All 3 will read your project and ensure that all dependencies are copied and installed properly. Options 2 and 3 offer much more flexibility, though a steeper learning curve.

I tried your methods but I got some errors.

What errors did you get?

Run-Time error '339'
Component MSCOMCTL.OCX or one of its dependencies not correctly registered a file is missing or invalid.

Run-time error 339 is a common error message that appears when a software application tries to access a specific file, but the file is either missing or corrupt. This error is typically caused by an issue with the Microsoft Common Control Library (MSCOMCTL.OCX), which is a file that is used by many different applications.

To fix this error, you will need to register the MSCOMCTL.OCX file on your computer. To do this, you can use the following steps:

Close the software application that is causing the error message to appear.

Open the Start menu and type "cmd" into the search box.

Right-click on the "Command Prompt" result and select "Run as administrator" from the context menu.

In the Command Prompt window, type the following command and press Enter:

regsvr32 C:\Windows\SysWOW64\MSCOMCTL.OCX

Note: If you are using a 32-bit version of Windows, you will need to use the following command instead:

regsvr32 C:\Windows\System32\MSCOMCTL.OCX

The system will now attempt to register the MSCOMCTL.OCX file on your computer. If the file is successfully registered, you will see a message that says "DllRegisterServer in MSCOMCTL.OCX succeeded."

Close the Command Prompt window and try to run the software application again. The error message should no longer appear.

If the error persists, you may need to download and install the latest version of the MSCOMCTL.OCX file from the internet. This can typically be done by searching for the file on a reputable download website and following the on-screen instructions to install it on your computer. Once the file has been installed, you can try registering it again using the steps outlined above.

I got it. I didn't know that I have to register the .ocx file.
Can I ask you, something not working in my project such as the Searches button(form1) in search area . also my routine to Load_SpecificID(form2) is not working, can you help me with that . I got error saying : "Index out of Bound" , I am not sure whats wrong.
I mean in form 2 I just want to see the Specific ID TT related.
And other thing when I delete SITES or STATUS, I got error when I tried to add again,I think that when I delete the data, I have to delete the 'ENTER' too, but it is not deleting.
Can you help me please?
Thank you very much for your patience and your help.
See my project in attached

The project has gotten a lot more complex. Starting to shape up nicely. I fixed the search. The out of bounds error happens when you use the count property in your for/next loop and delete an item inside the loop. You'll see how it's fixed. Your Sites and Status error occurred because DataFile is a public variable and your routine changed the value, so you were opening the wrong file. Fixed. I'm not sure what is not working for Form2. Can you explain further?

Two suggestions:

  1. Sort your procedures alphabetically. It helps find subroutines.
  2. You are using control arrays but not taking advantage of the purpose. Thus, you have a quite a few command button routines. You should consider consolidating these and using Select Case Index, where appropriate. Can save that for next time.

Well done. Your explanation are really clear, thanks!
the purpose of form 2 is only to load transactions from the clicked ticket.
for example:
I would like to see the transactions made by the ticket with ID: 2 . I double click in Listview1 and form2 opens and filters which transactions are registered for the ticket with ID: 2.
The logic I thought was:
By clicking on the required TT ID,
form1(Text1.text) will send to form2 the TT ID (Text8.text) and Listview2 will filter by Text8.text automatically.
which means that Listview2 will load filtering the TT ID 2 informations.

and the last thing, I saw you fixed the delete in txt routine, but there is a 'blank gap' (looks like 'ENTER') where I deleted the data , and the combobox will read the 'blank gap' as well , if possible when delete the data , delete this gap as well ?

Thanks for you help , much appreciate it.

I can't test it because there's no longer a subroutine called Clear_Fields in Form1. The Delete button seems to work for me in Form2.

Hey SCBWV,
I fixed that part to see the transactions from the each ticket.
but now i just wanted to find out how to delete data directly in txt file, because this method i was using just deleting in listview and save in txt file, which means that I will mess up the database.
do you know how to delete straight from txt file? not using listview. just delete the data and remove the 'blank gap'

See in attached.

Hey SCBWV,
I had the idea of using a textbox as support to delete the value in form2. however after deleting if I try to add I get error because there is that 'blank gap' in the txt. Can you help me with this?

See attached.

Well, so far, I can see an error when deleting an item. There's an invalid index error in the PopulateListView3 Sub because you're trying to assign SubItems 4 and 5 when ListView3 doesn't have that many columns. There's no direct way I can recall of deleting a specific data line from a text file without reading each line and comparing it to the desired item. It would take two text files - reading the source lines and outputting them to another text file if the line isn't the one to be deleted. Deleting the source and renaming the new text file. That can get messy in a hurry. I have never received an error you mentioned about reading past the end of the file or the "ENTER" as you called it. Can you tell me what steps to take to reproduce the error so I can help you?

The easiest way is to rebuild the text file based on the ListView each time the ListView changes. The text file would be overwritten, thus eliminating the item that was deleted.

Your project has now grown to having multiple text files used as a database table with 8 or 9 "fields." It's going to start getting complicated. At some point, you should consider using a database program to manage your data files. You can use the standard controls you have or consider using the ADO control with data bound controls such as the list. Would make your program much easier to manage.

this project would be a personal project, because where I work there is a system that contains all this information, but only managers have access. We can only store our data in txt files. The idea of creating a portable application without the need for installation is to save our data in txt more quickly. We cannot use databases, spreadsheets or microsoft access. text files only :/

When I delete the data need to delete this 'blank gap' as well , did you get me ? See the img

Imagem1.jpg

See if this works. You had a problem in the Delete Data sub. Your DataFile was pointing to Notes.Txt instead of Tickets.txt. Also, you Dim'd a variable called remove, which is a keyword for ListViews, so I changed it. There was an issue with the Sites combobox not getting populated after you delete an item because you clear in the Clear fields sub. By changing it to a dropdown combo, you can clear the text of the ComboBox without clearing the list it contains, which I've done.

Did you delete and add new 'sites' many times and did it work for you?
Are you adding and removing data without leaving a 'blank gap'?
because It didn't work for me. :/

So as not to get confused, going back to version 1, I tried to delete the data but it doesn't delete the 'blank gap', I think if we managed to delete this 'blank gap' we won't have this error anymore.
Error when populate listview after delete data and tried to add new data:
[
Run-Time error '9':
Subscript out of range
]

See attached version 1

I never had the deletion create a blank space in the data file. However, you can test for it in the PopulateListview sub as such:

        If LenB(Tmp$) Then
            Result = Split(Tmp$, "|")
            Set itmx = ListView1.ListItems.Add()
            itmx.Text = Result(0)
            itmx.SubItems(1) = Result(1)
            itmx.SubItems(2) = Result(2)
            itmx.SubItems(3) = Result(3)
        End If

well, Your method worked so that Listview doesn't get error anymore, but for the comboboxes it still gets 'blank gaps', I'm struggling to remove all these 'blank gaps' from the text file, I did this routine it removes all the 'blank gaps' and puts them all on the last lines, now I need to think about how to remove them from the text file.

Private Sub DeleteBlankSpaces()
    Call Pathway(way) ''''SET FOLDER WAY
    LogFileName = way & "\users.txt"   'Set file name

    Dim intFF As Integer
    Dim strTmp As String

    intFF = FreeFile
    Open way & "\users.txt" For Input As #intFF
      strTmp = Input(LOF(intFF), #intFF)
    Close #intFF

    Do While InStr(1, strTmp, vbCrLf & vbCrLf) > 0
      strTmp = Replace(strTmp, vbCrLf & vbCrLf, vbCrLf)
    Loop

    intFF = FreeFile
    Open way & "\users.txt" For Output As #intFF
      Print #intFF, strTmp
    Close #intFF
End Sub

That's why I suggested overwriting the text with the ListView items. Blank lines would be eliminated automatically.

The only way I know how to eliminate blank lines without the ListView method is to:

  1. Open the text file
  2. Create a temporary text file
  3. Read the text file line by line, outputting it to the temporary text file if the line is not blank
  4. Close the text file
  5. Close the temporary text file
  6. Delete the text file
  7. Rename the temporary file to the old text file name

As you can see, this is a LOT more clunky than:

  1. Open text file
  2. For each itm in LivewView1.ListItems output the item text and subtitems to the text file
  3. Close text file

yeah , I took your idea, and changed the project, it seems to be working fine. Now I'm in the Links area, I'm trying to open all the links in Listview2 but it only opens the first one in the list. do you know why ? Also when I edit or delete data , the Listview2 it is loading the data wrongly. Can you give me a hand?

Thanks for your patience and your help.

See attached

I've changed the tab control to an SSTab than the tab strip. The SSTab is much easier to work with. I added ShellExecute, which handles loading all your links now. It's never a good idea to hard code paths to installed programs, as you can never be sure where a user chose to install, Also, I have neither FireFox nor Chrome, so your code would never work for me.

I haven't a clue what you're trying to achieve with the ListViews in the Links tab. Perhaps if you explain how you intend them to work, I might be able to help?

Wow, you made it very gooood.
but the listview4 and listview2 seem to be crazy. when I add some data it does it correctly, but when I delete the data it loads wrongly.
The idea of the links tab is to save my links and put some as favorites, so when I start my shift I click 'open all favorites' and it will open all my favorite links. thats it.
my logic was: I add a link with the value 1(Text19) in listview4 and when I click 'Add' the value 1 becomes 2. and in listview2 only the values 2 will be populated.
Do you have any other ideas for saving links and adding favorites?

This is how I would do it...

Hey SCBWV,
Sorry I didn't answer you earlier because I was sick. I saw what you did and you did well.
Last help
I have 3 textboxes :
Text1 will receive 18 digits
Text2 needs to get last 8 digits
and Text3 needs to take Text2 value and make the opposite text.
for exemple:
Text1 = 80ad0120327405c1d8
Text2 will show= 7405c1d8
and
Text3 will do the reverse text = D8C10574

I tried but I couldnt get success.
and I would like to say , thank you very much.

Sorry , I didn't mention about the last 8 digits .
It can happen only with last 8 digits , the rest we can delete

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.