473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Help comparing and killing.

Hi I am having a little bit of trouble looking for a file in a directory that has random letters & numbers after "D20" how would i use the Dir command to check if this file exists while using the InStr function to get the file name of the file starting with "D20" and then killing it.

Much help is appreciated thanks.
Mar 16 '07 #1
5 1111
Visual Basic 6.0 anyone go any suggestions please?
Mar 17 '07 #2
vijaydiwakar
579 512MB
Hi I am having a little bit of trouble looking for a file in a directory that has random letters & numbers after "D20" how would i use the Dir command to check if this file exists while using the InStr function to get the file name of the file starting with "D20" and then killing it.

Much help is appreciated thanks.
dear i want more detail.
and sho me ur code so far
Mar 17 '07 #3
Another program creates a few cache files wich i want to delete there are certain characters that are always the same in the name at the start "D20" and then the rest of the characters are random. I want to check if this file exists by using the dir function and then if it does exist delete it.

'retval1 = Dir$(App.Path & "\D20*.dat")
'If retval = "\D20*.dat" Then
'Kill (TxtDirectory.Text & "\D20*.dat")
'End If

This does not work as * or ? doesn't represent flaged characters. How would i go about doing this correctly. Thanks
Mar 17 '07 #4
vijaydiwakar
579 512MB
Another program creates a few cache files wich i want to delete there are certain characters that are always the same in the name at the start "D20" and then the rest of the characters are random. I want to check if this file exists by using the dir function and then if it does exist delete it.

'retval1 = Dir$(App.Path & "\D20*.dat")
'If retval = "\D20*.dat" Then
'Kill (TxtDirectory.Text & "\D20*.dat")
'End If

This does not work as * or ? doesn't represent flaged characters. How would i go about doing this correctly. Thanks
first collect all the file names in a array then apply left$(myarr(i),3)="D20" then kill it
Mar 17 '07 #5
Killer42
8,435 Expert 8TB
...
'retval1 = Dir$(App.Path & "\D20*.dat")
'If retval = "\D20*.dat" Then
'Kill (TxtDirectory.Text & "\D20*.dat")
'End If
Actually, this code looks fine apart from a couple of things.
  • It's commented out. :D
  • You're checking the wrong variable (retval instead of retval1).
  • Retval will contain just the file name, no wildcard characters and no "\" at the front.
  • Why two different paths? (App.Path -vs- TxtDirectory.Text)
You might try something like this...
Expand|Select|Wrap|Line Numbers
  1. retval = Dir$(App.Path & "\D20*.dat")
  2. If retval <> "" Then
  3.   Kill (App.Path & "\" & retval)
  4. End If
Mar 19 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Colin Steadman | last post by:
I have created a function to kill all session variables that aren't in a safe list. This is the function - Sub PurgeSessionVariables For Each Item In Session.Contents Select Case Trim(Item)...
27
by: SK | last post by:
Hi I am trying to teach myself how to program in C. I am a physician hoping to be able to help restructure my office. Anyhow, I amhoping that the porblem I am having is simple to those much more...
4
by: Abdessamad Belangour | last post by:
Hi all, I have an ArrayList ( phoneBook ) of structures (PhoneEntry's) holding the name and the owned phone numbers of a person as in below :...
1
by: Stephen | last post by:
I am trying to compare the tables in two similar databases using the SQLDMO object. I am able to use this object to access different SQL servers and choose two different databases. The versions of...
12
by: D. Shane Fowlkes | last post by:
This is a repost (pasted below). Since my original post, I've double checked the system clock and set all IIS Session Timeout values to 10 minutes. Still ...the problem occurs. I've also...
5
by: MS Newsgroups | last post by:
Hi, I have an application that runs a timer and executes a method in a class as a new thread every 60 seconds, the thread takes 65 seconds to execute so there is a 5 second overlap when 2...
3
by: Richard Bell | last post by:
I'm working on a VB application that must run 24x7 for a LONG time, think 60 days of so. As part of what it does it must automate an instance of IE and navigate to many different URLs, think many...
19
by: Dennis | last post by:
I have a public variable in a class of type color declared as follows: public mycolor as color = color.Empty I want to check to see if the user has specified a color like; if mycolor =...
6
by: Roger Heathcote | last post by:
sjdevnull@yahoo.com wrote: <snip> Fair point, but for sub processes that need to be in close contact with the original app, or very small functions that you'd like 100s or 1000s of it seems...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.