|
I used a listview. I don't like the multi column behavior of a listbox. If you want to go through sub directories as well there is more to it obviously
1) Setup a listview
2) make sure you change it's 'view property to 'detail'
3) edit columns. add 2 call and them "File Name" and "Extension"
4) include the code below to populate it.
Imports System.IO
Public Class Form2
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim oItem As ListViewItem
For Each sFile As String In Directory.GetFiles("c:\picturePath")
oItem = New ListViewItem(Mid(sFile, InStrRev(sFile, "\") + 1).ToLower)
oItem.SubItems.Add(Mid(sFile, InStrRev(sFile, ".") + 1))
Me.ListView1.Items.Add(oItem)
oItem = Nothing
Next
End Sub
End Class
|
|
|
|
|
Thanx, but is there a way to only display image file names in the list? The code you gave me adds all files in a dir
--Zaegra--
|
|
|
|
|
sure you just need to apply a filter
Imports System.IO
Public Class Form2
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim oItem As ListViewItem,sExt as string
For Each sFile As String In Directory.GetFiles("c:\picturePath")
sExt = Mid(sFile, InStrRev(sFile, ".") + 1).tolower()
Select case sExt
case "bmp","gif","tif","jpg","jpeg" 'etc.
oItem = New ListViewItem(Mid(sFile, InStrRev(sFile, "\") + 1).ToLower)
oItem.SubItems.Add(sExt)
Me.ListView1.Items.Add(oItem)
oItem = Nothing
case else
'ignore file
end select
Next
End Sub
End Class
|
|
|
|
|
I have a function that should format a alpha numeric partnumber but it doesnt always work. not sure what i am missing here.
I have the partnumber defined as LONG , which only works on numeric part numbers. However, when I change it to a STRING the function throws an error "Unable to cast object of type 'System.String' to type 'System.IFormatProvider'.". Any advice would be greatly appreciated.
sample data that would be passed into the function follows
partnumber = 1243bu format= ##-###
Code:
Public Function FormatPartNumber(ByVal formatstyle As String, ByVal partnumber As String) As String
'FormatPartNumber = String.Format(formatstyle, partnumber)
Return partnumber.ToString(formatstyle)
End Function
jds1207
|
|
|
|
|
Imports System.IO
Public Class Form2
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
MsgBox(FormatPartNumber("00-000", "3aA33A"))
End
End Sub
Public Function FormatPartNumber(ByVal formatstyle As String, ByVal partnumber As String) As String
If IsNumeric(partnumber) Then Return CLng(partnumber).ToString(formatstyle)
If partnumber.Length < formatstyle.Length Then partnumber.PadLeft(formatstyle.Length, "0")
Dim sFormatted As String = String.Empty
Dim iFPos As Int16 = formatstyle.Length, iPPos As Int16 = partnumber.Length
Do While iFPos > 0
If Mid(formatstyle, iFPos, 1) = "0" Then
sFormatted = Mid(partnumber, iPPos, 1) & sFormatted
iPPos -= 1
iFPos -= 1
ElseIf Mid(formatstyle, iFPos, 1) = "-" Then
sFormatted = "-" & sFormatted
iFPos -= 1
End If
Loop
If iPPos > 0 Then
Do While iPPos > 0
sFormatted = Mid(partnumber, iPPos, 1) & sFormatted
iPPos -= 1
Loop
End If
Return sFormatted
End Function
End Class
|
|
|
|
|
Getting the following error: Conversion from string "0022BU" to type 'Long' is not valid.
Any suggestions!
|
|
|
|
|
did you use my code as is? the 2nd argument is type 'string'.
this line should of caught that
If IsNumeric(partnumber) Then Return CLng(partnumber).ToString(formatstyle)
if it's not numeric then it will positionally replace the format with the value.
|
|
|
|
|
Yes, I did use your code as is and I am still getting the same error.
|
|
|
|
|
i don't know what to tell you. i plugged in your value and got 002-2BU like I expected. try catch it then.
try
Return CLng(partnumber).ToString(formatstyle)
catch
end try
'if it is numeric then it will return formatted
'else it falls below to the rest of the code
|
|
|
|
|
Hi, guys. I need to know how to create a users and programmers manual for a vb.net proyect. Is there any software to help me or do I have to do it all??
Please help, ´cause I´m new in this.
Thank you very much for your time an effort.
Rafael Aguilar Sol
|
|
|
|
|
That depends on the type of project you're talking about and which version of VB.NET you're using.
If you're talking about a control, library, or web server project, then you would comment your code appropriately. But, how you do this depends on the version of VB.NET you're using. For 2002 and 2003, there is no built in support for generating XML Documentation at compile time, so you have to use a 3rd party tool, like VBCommentor (Google it!), and follow it's documentation on how you have to format your comments in your code.
For 2005, there is built in support for this. All you have to do follow the documentation here[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Ok. Thank you, Dave. I´m using the 2003 version so I´ll look for the VBCommentor.
Thanks a lot and God bless.
Rafael Aguilar Sol
|
|
|
|
|
I am working on large-scale project entitled as MIS (Marketing information System). As I told you that I am using Vb 6 as front end, Ms Access as back end and Crystal report 8 as reporting tool.
1) In the project it is required to save dealer’s photo, and it should be shown in individual dealer’s detail report, which will include his/her image. I had taken Common dialog box control to select image and display it in image control.
2) The size of database is very large then, which will be useful from the following?
i. to store image to database?
(But it makes database larger in size which leads to slower access)
ii. Saving path of image in database
To keep database safe I want to try the second option first. Instead coding directly into project, I want test the logic into small program first. As we know that by use of common dialog control we can select image and show it in image control. Also same path can be stored in database. Also we can retrieve the path from database and show it image control.
Until here all things are ok. Now problem is that how to show the image in crystal report. Usually we pass the fields directly to crystal report by sending sql-query to it.
If you require more details, please let me know. I will make it available.
Regards,
Kiran.
-- modified at 1:42 Saturday 4th November, 2006
Kiran Sajanikar
Software Engineer
CleverBIT softwares.
Pune.
|
|
|
|
|
How can i swap two values in database which are retrived in a combobox. Means in selectitem index i m using a event. But I have no idea how should I code for that event.
|
|
|
|
|
Pl. explain by an example
cheers,
Akhilesh Yadav
|
|
|
|
|
|
Hello,
I have this code below but i want to specify it in 24hr format.
time = ScheduledTime.ToString("hh:mm")
I have my sql server 2005 database set for nvarchar but the actual input that is always entered as a date along with the time. e.g. 2/11/2006 10:34
I would just like to have the time specified.
Thanks,
Steve
-- modified at 4:34 Friday 3rd November, 2006
|
|
|
|
|
Try using captial HH for example
time = format(ScheduleTime, "HH:mm")
this should provide the time in 24 hour system where as
time = format(ScheduleTime, "hh:mm")
will provide the time in the 12 hour system
Steve Jowett
|
|
|
|
|
Thanks,
Thanks worked great.
|
|
|
|
|
I m using combobox to get values from database. I want to swap two values of dropdwon list with each other in an event. Can any one give me idea of that event.
|
|
|
|
|
Which values? Is it to be sequential e.g. swap item at index 0 with item at index 1? Or non-sequential e.g. swap item at index 0 (or any other) with any other item in the index (swap item 4 with 9, 2 with 1, 6 with 13)?
Either way the event that you're looking for is the SelectedIndexChanged event.
|
|
|
|
|
Safecom wrote: I m using combobox to get values from database.
No, you are using a DataProvider to get values from the database.
Those values are provided to you in a stream.
You can put those values into various containers, eg. a DataTable, an Array of List Objects, etc. which can then be fed or bound to your control.
They should be encapsulated in a list of business objects, (preferably using a list type that implements IList - ArrayList is good) which is then manipulated (sorted according to your business rules, which may change momentarily by user gestures such as clicking radio buttons, checkboxes, etc.) and then presented to the user in the ComboBox. You may need to add a suitable sort key to your business object to help with the re-sorting/swapping.
You can do all that off the DropDown event if necessary, but you will take a performance hit. It would be better to evaluate your conditions beforehand if possible, using other control events, and re-sort the list (and rebind the list to the control) before the user drops it down.
SelectedIndexChange is too late. The user has already seen the list.
|
|
|
|
|
Hey guys,
if i have a Dll build using C#
can i import it into Vb.net?
wel i tried (in vb.net 2005) ADD REFERENCE,the DLL was added but i couldnt see the Dll in the Solution Exploere,thus I coulndt call the DLL
Regards
Ramy
|
|
|
|
|
It should be in your references?
"a fool will not learn from a wise man, but a wise man will learn from a fool"
"It is hard to fail, but it is worse never to have tried to succeed." - Theodore Roosevelt
"Success is going from failure to failure without losing your enthusiasm." - Winston Churchill
My Website || My Blog
|
|
|
|
|
Here's how ours is set up:
We have a Solution file, with a number of VB.Net projects in it, and one CS project, which I think was supplied by a vendor as a hotfix.
One of the VB projects has a reference to the CS project, and creates an instance of the component in it.
The project is obviously visible in the Solution Explorer, and also in ObjectBrowser.
Both versions of the component in the CS project show up under the same Namespace in the ObjectBrowser, however one of them has [Runtime = v2.0.50727] annotated after it.
(This may have no bearing on your solution.)
So it looks like you need a solution file, with the CS project added to it, and a reference set to it in the calling VB project.
Hope this helps.
Dave
|
|
|
|