|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem populating a combobox if cases differa .png extension. Hers what i have... Dim strFileName As String 620 frmMain.cboEffect.AddItem "None" 630 strFileName = Dir$(strShortPath & "\*.png") 640 strFileName = Replace(strFileName, ".png", "") 650 strFileName = StrConv(strFileName, vbProperCase) 660 While strFileName <> "" 670 frmMain.cboEffect.AddItem strFileName 680 strFileName = Replace(Dir$, ".png", "") 690 strFileName = StrConv(strFileName, vbProperCase) 700 Wend I want to remove the .png extension in the combobox. The problem is, if the ..png is .PNG, it is not working. How do i correct this? -- Thanks. Saucer Man wrote:
Show quoteHide quote > I am trying to populate a combobox with all files in a certain folder with Try :> a .png extension. Hers what i have... > > Dim strFileName As String > 620 frmMain.cboEffect.AddItem "None" > > 630 strFileName = Dir$(strShortPath & "\*.png") > 640 strFileName = Replace(strFileName, ".png", "") > 650 strFileName = StrConv(strFileName, vbProperCase) > 660 While strFileName <> "" > 670 frmMain.cboEffect.AddItem strFileName > 680 strFileName = Replace(Dir$, ".png", "") > 690 strFileName = StrConv(strFileName, vbProperCase) > 700 Wend > > I want to remove the .png extension in the combobox. The problem is, if the > .png is .PNG, it is not working. How do i correct this? > strFileName = Replace(strFileName, ".png", "",,vbTextCompare) Regards, Paul. That didn't work. I think the problem is in line 680. The DIR$ is getting
the next file but it is an uppercase PNG. The replace is not working as when the program flows to line 690, strFileName still has the uppercase ..PNG. -- Show quoteHide quoteThanks. "Paul Lambert" <paul.lamb***@autoledgers.com.au> wrote in message news:45E21D62.6070102@autoledgers.com.au... > Saucer Man wrote: >> I am trying to populate a combobox with all files in a certain folder >> with a .png extension. Hers what i have... >> >> Dim strFileName As String >> 620 frmMain.cboEffect.AddItem "None" >> >> 630 strFileName = Dir$(strShortPath & "\*.png") >> 640 strFileName = Replace(strFileName, ".png", "") >> 650 strFileName = StrConv(strFileName, vbProperCase) >> 660 While strFileName <> "" >> 670 frmMain.cboEffect.AddItem strFileName >> 680 strFileName = Replace(Dir$, ".png", "") >> 690 strFileName = StrConv(strFileName, vbProperCase) >> 700 Wend >> >> I want to remove the .png extension in the combobox. The problem is, if >> the .png is .PNG, it is not working. How do i correct this? >> > > Try : > > strFileName = Replace(strFileName, ".png", "",,vbTextCompare) > > Regards, > Paul. > > -- > Posted via a free Usenet account from http://www.teranews.com > Saucer Man wrote:
> That didn't work. I think the problem is in line 680. The DIR$ is getting Do the same thing to line 680 as well.> the next file but it is an uppercase PNG. The replace is not working as > when the program flows to line 690, strFileName still has the uppercase > .PNG. > I.e. adding the ,,vbTextCompare to the end of your replace function call. I did. I replaced both instances but it doesn't work.
-- Show quoteHide quoteThanks. "Paul Lambert" <paul.lamb***@autoledgers.com.au> wrote in message news:45E227D4.2000006@autoledgers.com.au... > Saucer Man wrote: >> That didn't work. I think the problem is in line 680. The DIR$ is >> getting the next file but it is an uppercase PNG. The replace is not >> working as when the program flows to line 690, strFileName still has the >> uppercase .PNG. >> > Do the same thing to line 680 as well. > > I.e. adding the ,,vbTextCompare to the end of your replace function call. > > -- > Posted via a free Usenet account from http://www.teranews.com > "Saucer Man" <saucerman@nospam.net> wrote in message news:IjpEh.41719$19.33892@bignews3.bellsouth.net... Function ProperName(FileName As String) As String> That didn't work. I think the problem is in line 680. The DIR$ is getting > the next file but it is an uppercase PNG. The replace is not working as > when the program flows to line 690, strFileName still has the uppercase > .PNG. > Dim pos As Long pos = InStr(LCase$(FileName), ".png") If pos > 0 Then ProperName = StrConv(Left$(FileName, pos - 1), vbProperCase) End If End Function LFS Larry, does this function replace any case combination of "png" with ""?
That's what I am trying to accomplish. -- Show quoteHide quoteThanks. "Larry Serflaten" <serfla***@usinternet.com> wrote in message news:u8S6GyTWHHA.4844@TK2MSFTNGP03.phx.gbl... > > "Saucer Man" <saucerman@nospam.net> wrote in message > news:IjpEh.41719$19.33892@bignews3.bellsouth.net... >> That didn't work. I think the problem is in line 680. The DIR$ is >> getting >> the next file but it is an uppercase PNG. The replace is not working as >> when the program flows to line 690, strFileName still has the uppercase >> .PNG. >> > > > Function ProperName(FileName As String) As String > Dim pos As Long > pos = InStr(LCase$(FileName), ".png") > If pos > 0 Then > ProperName = StrConv(Left$(FileName, pos - 1), vbProperCase) > End If > End Function > > LFS > > > Larry, does this function replace any case combination of "png" with ""? Larry's code doesn't replace any text; what it does is find the ".png" (with > That's what I am trying to accomplish. any initial case), and then truncates the text (that's what the Left$ function does) in front of its dot (and, afterward, proper cases the result). Rick "Saucer Man" <saucerman@nospam.net> wrote It doesn't use Replace. It removes those characters (and any following) from> Larry, does this function replace any case combination of "png" with ""? > That's what I am trying to accomplish. the string. You'd use it something like: strFileName = Dir$(strShortPath & "\*.png") strFileName = ProperName(strFileName) While Len(strFileName) > 0 frmMain.cboEffect.AddItem strFileName strFileName = ProperName(Dir()) Wend LFS
Show quote
Hide quote
"Saucer Man" <saucerman@nospam.net> wrote in message VB doesn't need line numbers.news:eIoEh.44789$I8.351@bignews8.bellsouth.net... >I am trying to populate a combobox with all files in a certain folder with >a .png extension. Hers what i have... > > Dim strFileName As String > 620 frmMain.cboEffect.AddItem "None" > > 630 strFileName = Dir$(strShortPath & "\*.png") > 640 strFileName = Replace(strFileName, ".png", "") > 650 strFileName = StrConv(strFileName, vbProperCase) > 660 While strFileName <> "" > 670 frmMain.cboEffect.AddItem strFileName > 680 strFileName = Replace(Dir$, ".png", "") > 690 strFileName = StrConv(strFileName, vbProperCase) > 700 Wend Michael I know. I use line numbers for error trapping.
-- Show quoteHide quoteThanks. "Michael C" <nospam@nospam.com> wrote in message news:%23sreMfTWHHA.5108@TK2MSFTNGP06.phx.gbl... > "Saucer Man" <saucerman@nospam.net> wrote in message > news:eIoEh.44789$I8.351@bignews8.bellsouth.net... >>I am trying to populate a combobox with all files in a certain folder >>with a .png extension. Hers what i have... >> >> Dim strFileName As String >> 620 frmMain.cboEffect.AddItem "None" >> >> 630 strFileName = Dir$(strShortPath & "\*.png") >> 640 strFileName = Replace(strFileName, ".png", "") >> 650 strFileName = StrConv(strFileName, vbProperCase) >> 660 While strFileName <> "" >> 670 frmMain.cboEffect.AddItem strFileName >> 680 strFileName = Replace(Dir$, ".png", "") >> 690 strFileName = StrConv(strFileName, vbProperCase) >> 700 Wend > > VB doesn't need line numbers. > > Michael > "Saucer Man" <saucerman@nospam.net> wrote in message So do I but I have an addin that does them sequentially for each line news:%VpEh.11635$e8.765@bignews1.bellsouth.net... >I know. I use line numbers for error trapping. starting at 1 for each routine. It also skips lines that cannot error such as End If. Michael I'm using an add-on also.
-- Show quoteHide quoteThanks. "Michael C" <nospam@nospam.com> wrote in message news:ucbhT8UWHHA.1120@TK2MSFTNGP02.phx.gbl... > "Saucer Man" <saucerman@nospam.net> wrote in message > news:%VpEh.11635$e8.765@bignews1.bellsouth.net... >>I know. I use line numbers for error trapping. > > So do I but I have an addin that does them sequentially for each line > starting at 1 for each routine. It also skips lines that cannot error such > as End If. > > Michael > "Saucer Man" <saucerman@nospam.net> wrote in message Why does it increment by 10 then?news:lNDEh.21932$m7.7672@bignews5.bellsouth.net... > I'm using an add-on also. Michael Probably because thats what the add-on is set for by default. I didn't
change it. -- Show quoteHide quoteThanks. "Michael C" <nospam@nospam.com> wrote in message news:OIkGPffWHHA.480@TK2MSFTNGP02.phx.gbl... > "Saucer Man" <saucerman@nospam.net> wrote in message > news:lNDEh.21932$m7.7672@bignews5.bellsouth.net... >> I'm using an add-on also. > > Why does it increment by 10 then? > > Michael > "Saucer Man" <saucerman@nospam.net> wrote in message If you reverse those two lines you'll know that the .png is lower case innews:eIoEh.44789$I8.351@bignews8.bellsouth.net > I am trying to populate a combobox with all files in a certain > folder with a .png extension. Hers what i have... > > Dim strFileName As String > 620 frmMain.cboEffect.AddItem "None" > > 630 strFileName = Dir$(strShortPath & "\*.png") > 640 strFileName = Replace(strFileName, ".png", "") > 650 strFileName = StrConv(strFileName, vbProperCase) the filename. > 660 While strFileName <> "" invert those two as well> 670 frmMain.cboEffect.AddItem strFileName > 680 strFileName = Replace(Dir$, ".png", "") > 690 strFileName = StrConv(strFileName, vbProperCase) > 700 Wend Adding the optional vbTextCompare argument should also have worked for you> > I want to remove the .png extension in the combobox. The problem is, > if the .png is .PNG, it is not working. How do i correct this? -- Reply to the group so all can participate VB.Net: "Fool me once..." I reversed the last two lines in both groups and that didn't work either.
I'm curious why I can't get this work by adding the vbTextCompare. I am using SP5. Is there an issue with that in SP5? -- Show quoteHide quoteThanks. "Bob Butler" <tiredofit@nospam.ever> wrote in message news:eSz0Q8TWHHA.4832@TK2MSFTNGP04.phx.gbl... > "Saucer Man" <saucerman@nospam.net> wrote in message > news:eIoEh.44789$I8.351@bignews8.bellsouth.net >> I am trying to populate a combobox with all files in a certain >> folder with a .png extension. Hers what i have... >> >> Dim strFileName As String >> 620 frmMain.cboEffect.AddItem "None" >> >> 630 strFileName = Dir$(strShortPath & "\*.png") >> 640 strFileName = Replace(strFileName, ".png", "") >> 650 strFileName = StrConv(strFileName, vbProperCase) > > If you reverse those two lines you'll know that the .png is lower case in > the filename. > >> 660 While strFileName <> "" >> 670 frmMain.cboEffect.AddItem strFileName >> 680 strFileName = Replace(Dir$, ".png", "") >> 690 strFileName = StrConv(strFileName, vbProperCase) > > invert those two as well > >> 700 Wend >> >> I want to remove the .png extension in the combobox. The problem is, >> if the .png is .PNG, it is not working. How do i correct this? > > Adding the optional vbTextCompare argument should also have worked for you > > -- > Reply to the group so all can participate > VB.Net: "Fool me once..." > Could the . in there be causing the problem with the text compare?
-- Show quoteHide quoteThanks. "Saucer Man" <saucerman@nospam.net> wrote in message news:gDEEh.21947$m7.19212@bignews5.bellsouth.net... >I reversed the last two lines in both groups and that didn't work either. >I'm curious why I can't get this work by adding the vbTextCompare. I am >using SP5. Is there an issue with that in SP5? > > -- > > Thanks. > > > "Bob Butler" <tiredofit@nospam.ever> wrote in message > news:eSz0Q8TWHHA.4832@TK2MSFTNGP04.phx.gbl... >> "Saucer Man" <saucerman@nospam.net> wrote in message >> news:eIoEh.44789$I8.351@bignews8.bellsouth.net >>> I am trying to populate a combobox with all files in a certain >>> folder with a .png extension. Hers what i have... >>> >>> Dim strFileName As String >>> 620 frmMain.cboEffect.AddItem "None" >>> >>> 630 strFileName = Dir$(strShortPath & "\*.png") >>> 640 strFileName = Replace(strFileName, ".png", "") >>> 650 strFileName = StrConv(strFileName, vbProperCase) >> >> If you reverse those two lines you'll know that the .png is lower case in >> the filename. >> >>> 660 While strFileName <> "" >>> 670 frmMain.cboEffect.AddItem strFileName >>> 680 strFileName = Replace(Dir$, ".png", "") >>> 690 strFileName = StrConv(strFileName, vbProperCase) >> >> invert those two as well >> >>> 700 Wend >>> >>> I want to remove the .png extension in the combobox. The problem is, >>> if the .png is .PNG, it is not working. How do i correct this? >> >> Adding the optional vbTextCompare argument should also have worked for >> you >> >> -- >> Reply to the group so all can participate >> VB.Net: "Fool me once..." >> > > Ok...it wasn't working because I need 3 commas before the vbTextCompare. I
only had two. Now it is working. Thanks again. -- Show quoteHide quoteThanks. "Saucer Man" <saucerman@nospam.net> wrote in message news:gPEEh.21952$m7.5368@bignews5.bellsouth.net... > Could the . in there be causing the problem with the text compare? > > -- > > Thanks. > > > "Saucer Man" <saucerman@nospam.net> wrote in message > news:gDEEh.21947$m7.19212@bignews5.bellsouth.net... >>I reversed the last two lines in both groups and that didn't work either. >>I'm curious why I can't get this work by adding the vbTextCompare. I am >>using SP5. Is there an issue with that in SP5? >> >> -- >> >> Thanks. >> >> >> "Bob Butler" <tiredofit@nospam.ever> wrote in message >> news:eSz0Q8TWHHA.4832@TK2MSFTNGP04.phx.gbl... >>> "Saucer Man" <saucerman@nospam.net> wrote in message >>> news:eIoEh.44789$I8.351@bignews8.bellsouth.net >>>> I am trying to populate a combobox with all files in a certain >>>> folder with a .png extension. Hers what i have... >>>> >>>> Dim strFileName As String >>>> 620 frmMain.cboEffect.AddItem "None" >>>> >>>> 630 strFileName = Dir$(strShortPath & "\*.png") >>>> 640 strFileName = Replace(strFileName, ".png", "") >>>> 650 strFileName = StrConv(strFileName, vbProperCase) >>> >>> If you reverse those two lines you'll know that the .png is lower case >>> in >>> the filename. >>> >>>> 660 While strFileName <> "" >>>> 670 frmMain.cboEffect.AddItem strFileName >>>> 680 strFileName = Replace(Dir$, ".png", "") >>>> 690 strFileName = StrConv(strFileName, vbProperCase) >>> >>> invert those two as well >>> >>>> 700 Wend >>>> >>>> I want to remove the .png extension in the combobox. The problem is, >>>> if the .png is .PNG, it is not working. How do i correct this? >>> >>> Adding the optional vbTextCompare argument should also have worked for >>> you >>> >>> -- >>> Reply to the group so all can participate >>> VB.Net: "Fool me once..." >>> >> >> > > "Saucer Man" <saucerman@nospam.net> wrote in message No; I think you need to post your revised code because something is notnews:gPEEh.21952$m7.5368@bignews5.bellsouth.net > Could the . in there be causing the problem with the text compare? being done correctly. -- Reply to the group so all can participate VB.Net: "Fool me once..." For fear of stating the obvious, as you know all the files will end ".PNG",.
why not just chop off the last 4 characters? Regards Dave O. Show quoteHide quote "Saucer Man" <saucerman@nospam.net> wrote in message news:eIoEh.44789$I8.351@bignews8.bellsouth.net... >I am trying to populate a combobox with all files in a certain folder with >a .png extension. Hers what i have... > > Dim strFileName As String > 620 frmMain.cboEffect.AddItem "None" > > 630 strFileName = Dir$(strShortPath & "\*.png") > 640 strFileName = Replace(strFileName, ".png", "") > 650 strFileName = StrConv(strFileName, vbProperCase) > 660 While strFileName <> "" > 670 frmMain.cboEffect.AddItem strFileName > 680 strFileName = Replace(Dir$, ".png", "") > 690 strFileName = StrConv(strFileName, vbProperCase) > 700 Wend > > I want to remove the .png extension in the combobox. The problem is, if > the .png is .PNG, it is not working. How do i correct this? > > -- > > Thanks. > > > How do you do that?
-- Show quoteHide quoteThanks. "Dave O." <nob***@nowhere.com> wrote in message news:ecYq7WZWHHA.4964@TK2MSFTNGP06.phx.gbl... > For fear of stating the obvious, as you know all the files will end > ".PNG",. why not just chop off the last 4 characters? > > Regards > Dave O. > > "Saucer Man" <saucerman@nospam.net> wrote in message > news:eIoEh.44789$I8.351@bignews8.bellsouth.net... >>I am trying to populate a combobox with all files in a certain folder >>with a .png extension. Hers what i have... >> >> Dim strFileName As String >> 620 frmMain.cboEffect.AddItem "None" >> >> 630 strFileName = Dir$(strShortPath & "\*.png") >> 640 strFileName = Replace(strFileName, ".png", "") >> 650 strFileName = StrConv(strFileName, vbProperCase) >> 660 While strFileName <> "" >> 670 frmMain.cboEffect.AddItem strFileName >> 680 strFileName = Replace(Dir$, ".png", "") >> 690 strFileName = StrConv(strFileName, vbProperCase) >> 700 Wend >> >> I want to remove the .png extension in the combobox. The problem is, if >> the .png is .PNG, it is not working. How do i correct this? >> >> -- >> >> Thanks. >> >> >> > >
Show quote
Hide quote
>>>I am trying to populate a combobox with all files in a certain folder Where you have this...>>>with a .png extension. Hers what i have... >>> >>> Dim strFileName As String >>> 620 frmMain.cboEffect.AddItem "None" >>> >>> 630 strFileName = Dir$(strShortPath & "\*.png") >>> 640 strFileName = Replace(strFileName, ".png", "") >>> 650 strFileName = StrConv(strFileName, vbProperCase) >>> 660 While strFileName <> "" >>> 670 frmMain.cboEffect.AddItem strFileName >>> 680 strFileName = Replace(Dir$, ".png", "") >>> 690 strFileName = StrConv(strFileName, vbProperCase) >>> 700 Wend >>> >>> I want to remove the .png extension in the combobox. The problem is, if >>> the .png is .PNG, it is not working. How do i correct this? >>> >> For fear of stating the obvious, as you know all the files will end >> ".PNG",. why not just chop off the last 4 characters? >> > How do you do that? strFileName = Replace(Dir$, ".png", "") replace it with this... strTemp = Dir$ strFileName = Left$(strTemp, Len(strTemp) - 4) remembering to add the Dim statement for the strTemp variable, of course. Rick Thanks for all the help everyone!!!
-- Show quoteHide quoteThanks. "Rick Rothstein (MVP - VB)" <rickNOSPAMnews@NOSPAMcomcast.net> wrote in message news:%23w7KcwcWHHA.5068@TK2MSFTNGP03.phx.gbl... >>>>I am trying to populate a combobox with all files in a certain folder >>>>with a .png extension. Hers what i have... >>>> >>>> Dim strFileName As String >>>> 620 frmMain.cboEffect.AddItem "None" >>>> >>>> 630 strFileName = Dir$(strShortPath & "\*.png") >>>> 640 strFileName = Replace(strFileName, ".png", "") >>>> 650 strFileName = StrConv(strFileName, vbProperCase) >>>> 660 While strFileName <> "" >>>> 670 frmMain.cboEffect.AddItem strFileName >>>> 680 strFileName = Replace(Dir$, ".png", "") >>>> 690 strFileName = StrConv(strFileName, vbProperCase) >>>> 700 Wend >>>> >>>> I want to remove the .png extension in the combobox. The problem is, >>>> if the .png is .PNG, it is not working. How do i correct this? >>>> >>> For fear of stating the obvious, as you know all the files will end >>> ".PNG",. why not just chop off the last 4 characters? >>> >> How do you do that? > > Where you have this... > > strFileName = Replace(Dir$, ".png", "") > > replace it with this... > > strTemp = Dir$ > strFileName = Left$(strTemp, Len(strTemp) - 4) > > remembering to add the Dim statement for the strTemp variable, of course. > > Rick >
Sad
Inline Assembly In VB6 Database connection problem on VB6.0 There seems to be a bug in Vista's file sharing that causes the ADO Database open command to hang if Localized Error Messages MS Winsock Control ports don't free up How to open a CMD Line exe as hidden and wat for it to finish Have a problem that is stumping me. VB6 DLL Assembly Compile Link how??? Full Control to Users programmatically |
|||||||||||||||||||||||