|
How does one retreive the directory path of a specific file chosen once you click on ok button on an openfiledialog? e.g. C:\test\data\textfile.txt
Thanks
|
|
|
|
|
Not sure what you mean. With the properties FileName and FileNames you can get the complete path from the OpenFileDialog - including the filename itself. If you only want the directory you can use System.IO.Path.GetDirectoryName function to remove the filename from a complete filepath.
|
|
|
|
|
Thanks the filenames works.
|
|
|
|
|
Hello,
I'm new on this page and on VB.Net and want's to create an simple control. But for this I need a property with DataType is collection. In the collection I want to have an object with two properties ('Prop' and 'Value'). I have defined this property, but VB.Net doesn't save my edits in the built in CollectionEditor.
At the Control I have inserted the following code:
<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)> _<br />
Public ReadOnly Property CustomProperties() As CustomPropertyCollection<br />
Get<br />
Return mvcolCustomPropertyCollection<br />
End Get<br />
End Property<br />
The definition of the CustomPropertyCollection and the object in the collection is:
Friend Class CustomPropertyConverter<br />
' Ohne den Konverter kann man nicht speichern<br />
Inherits System.ComponentModel.TypeConverter<br />
<br />
Public Overloads Overrides Function CanConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal destType As Type) As Boolean<br />
If destType Is GetType(System.ComponentModel.Design.Serialization.InstanceDescriptor) Then<br />
Return True<br />
End If<br />
<br />
Return MyBase.CanConvertTo(context, destType)<br />
End Function<br />
<br />
Public Overloads Overrides Function ConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object, ByVal destType As Type) As Object<br />
If destType Is GetType(System.ComponentModel.Design.Serialization.InstanceDescriptor) Then<br />
Dim cat As CustomProperty = DirectCast(value, CustomProperty)<br />
<br />
Dim ci As System.Reflection.ConstructorInfo = GetType(CustomProperty).GetConstructor(System.Type.EmptyTypes)<br />
<br />
Return New System.ComponentModel.Design.Serialization.InstanceDescriptor(ci, Nothing, False)<br />
End If<br />
<br />
Return MyBase.ConvertTo(context, culture, value, destType)<br />
End Function<br />
End Class<br />
<br />
<System.ComponentModel.TypeConverter(GetType(CustomPropertyConverter))> _<br />
Public Class CustomProperty<br />
Dim mvstrProperty As String<br />
Dim mvstrValue As String<br />
<br />
Public Property Prop() As String<br />
Get<br />
Prop = mvstrProperty<br />
End Get<br />
Set(ByVal pvstrProp As String)<br />
mvstrProperty = pvstrProp<br />
End Set<br />
End Property<br />
<br />
Public Property Value() As String<br />
Get<br />
Value = mvstrValue<br />
End Get<br />
Set(ByVal pvstrValue As String)<br />
mvstrValue = pvstrValue<br />
End Set<br />
End Property<br />
End Class<br />
<br />
Public Class CustomPropertyCollection<br />
Inherits CollectionBase<br />
<br />
'Needed to implement the strongly-typed collection<br />
Default Public Property Item(ByVal Index As Integer) As CustomProperty<br />
Get<br />
Return DirectCast(List.Item(Index), CustomProperty)<br />
End Get<br />
Set(ByVal Value As CustomProperty)<br />
List.Item(Index) = Value<br />
End Set<br />
End Property<br />
<br />
Public Function Add(ByVal Item As CustomProperty) As Integer<br />
Return List.Add(Item)<br />
End Function<br />
<br />
Public Sub Insert(ByVal index As Integer, ByVal Item As CustomProperty)<br />
If List.Contains(Item) Then<br />
Throw New InvalidOperationException("Already in list.")<br />
End If<br />
<br />
List.Insert(index, Item)<br />
End Sub<br />
<br />
Public Function Contains(ByVal value As CustomProperty) As Boolean<br />
Return List.Contains(value)<br />
End Function<br />
<br />
'Redraw the control<br />
Protected Overrides Sub OnClearComplete()<br />
MyBase.OnClearComplete()<br />
End Sub<br />
<br />
'Redraw the control and wire up button's redrawneeded event<br />
Protected Overrides Sub OnInsertComplete(ByVal index As Integer, ByVal value As Object)<br />
MyBase.OnInsertComplete(index, value)<br />
End Sub<br />
<br />
'Redraw the control<br />
Protected Overrides Sub OnRemoveComplete(ByVal index As Integer, ByVal value As Object)<br />
MyBase.OnRemoveComplete(index, value)<br />
End Sub<br />
End Class<br />
The Part with the Converter I have seen in a sample for this page (outlookbartest). I don't know if I need it...
Please help me...
Vocaris
|
|
|
|
|
I have a datagrid with 6 columns. column 6 is the balance column and column 4 is the amount payed.I need column4 row1 to subtract from column6 row1 and show in row2 column6.then I need column4 row2 to subtract from column6 row2 and show in column6 row3. I need this to loop or something.
any suggestions?
|
|
|
|
|
Not sure if that is what you need but sounds like:
for index=1 to datagrid.count-1
datagrid.rows(index).item("Column6")=datagrid.rows(index-1).item("Column6")-datagrid.rows(index).item("Column4")
next index
Briga
|
|
|
|
|
ummm... I dont understand why count is underlined as wrong and datagrid.rows is wrong??
any suggestions?
thanx
|
|
|
|
|
Well I replied quickly and typed the code just to give you the idea.
The error you get is because the count and rows should refer the realdatabase you have behing the datagrid (dataset or dataview or whatever). Since I don't know the architecure of your application I don't konw how to address it but you can easily transpose the following code:
Let's suppose you have a dataset called d1 with a table t1 with two columns: c1 & c2. Where c2 is the progressive total as you want.
You can create a sub passing the table, the index of the value column and the index of the progressive total column as follows:
private sub RecalcProgressive(dt as datatable,i1 as integer,i2 as integer)
dim index as integer
'
if dt.rows.count=0 then exit sub ' If no records then exit
dt.rows(0).item(i2)=dt.rows(0).item(i1) ' First line only progressive=value
if dt.rows.count=1 then exit sub ' If only one line then it's done
for index=1 to dt.rows.count-1 ' For each line in the DB
dt.rows(index).item(i2)=dt.rows(index).item(i1)+dt.rows(index-1).item(i2) ' Calc
next index
end sub
Then, according to the hypothesis before, you can call it:
public sub Main
<...>
RecalcProgressive(d1.t1,1,2)
<...>
end sub
Bye
Briga
|
|
|
|
|
|
How can create Setup File for VB6 Project with "Wise for windows Installer"?
|
|
|
|
|
better off with innosetup or others
|
|
|
|
|
Consult the "Wise For Windows Installer" documentation. You've asked a very vague question, listing no details of what you're having a problem with. On top that, this is the Visual Basic Forum, not a Wise Product Support Forum.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi..
i have make 3 forms
1 mdi parent and 2 mdi child
calling a child to show at parent is easy
but hoow to make a child call another child and show it in the parent?
this is basically how it look like..
form1(parent) call form2(child)....form2 show in form1
form2(child) call form3(child).....form3 show in form1
i try to code the button in form2
like so
Dim frm3 as New Form3
Dim frm1 as New Form1
frm3.mdiparent = frm1
frm3.show
which is not working...am i doing it wrong?
please help me...thank you in adnvace
Gary
|
|
|
|
|
Try this:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim frm2 As New Form2
frm2.MdiParent = Me
frm2.Show()
End Sub
End Class
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm3 As New Form3
frm3.MdiParent = Me.ParentForm
frm3.Show()
End Sub
End Class
|
|
|
|
|
tried....but this error show up
An unhandled exception of type 'System.NullReferenceException' occurred in WindowsApplication7.exe
Additional information: Object reference not set to an instance of an object.
and still unable to show the second child
Gary
|
|
|
|
|
Try Owner instead of ParentForm . ParentForm gets the form on which a control is placed. Owner should get (if I remember right) the owning form of a child form.
|
|
|
|
|
I'm sorry Gary, I tested my previous example on VisualBasic 2005 Beta and it works there. You're right it does produce an error on my VS 2003. I tested this on VS 2003 and it works.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm3 As New Form3
frm3.MdiParent = Me.MdiParent
frm3.Show()
End Sub
|
|
|
|
|
Thanks OIC
is working now
thank for all the help....both of u thank you
Gary
|
|
|
|
|
I am trying to delete any row selected using
<br />
Dim SelectRow() As DataRow = DS.Tables(0).Select()<br />
DS.Tables(0).Rows.Remove(SelectRow(0))<br />
But Since i have the selected row set to row 0 it only deletes row 0.
is there something I could put in the place of 0 to represent any selected row so that it will stop deleting only row 0?
thanks
|
|
|
|
|
hi; try this
DS.Tables(0).Rows(datagrid.SelectedIndex)
when you select any row in DG you can get the selected index and can use it to have the row from DS
thanx
|
|
|
|
|
Im confused because when I entered this the whole thing was underlined.you already know what that means im sure. should I be entering it elsewhere or what.
I greatly appreciate the time you are sparing to help me.
|
|
|
|
|
dear
use it where you need, i gave you the way to get any selected row in grid so use it in any method such as (dag.selectedindexchange) to get the selected row or the id or any thing
thanx
|
|
|
|
|
How can fetch data from .DBF data file(FoxPro)with VB6?
|
|
|
|
|
There is a ODBC driver which works with .dbf files. I think its called something like "Microsoft dBase driver" and can be downloaded somewhere on msdn. With it you can then access those files with the normal ADO mechanisms.
|
|
|
|
|
My Project is "Car Rental".
I hve the following doubts while designing and coding my work. I have one table called "Avaliablity" where i used to record information about the booked cars.
I am doing my project on car hire. Meanwhile i came across your site. Its really great. I have some questions too.
1. Once a customer booked a car am trying to put one entry in to 'Avaliablity Table' . So do i hve to refer this table in future if a second customer comes and demand the same car.
2. Also how can i keep the transaction table. i mean the "Booking Table" . Do i hve to keep the particular record open until the customer clear his amount or payment for the car rental.
3. I hve a GUI screen to add new vehicle to the Car rental agenty. do i hve to hve Edit option in the GUI screen for the "Vehicle Table". If so i should allow them to update the mileage only.
4. Do i hve to add "Payment Options" to my project.
|
|
|
|