20-04-2007, 03:39 AM | #1 | ||
Join Date: Oct 2004
Location: Godmanchester, England
Posts: 850
|
I'm Learning how to code in Visual Basic (with VB Express 2005) and i'm trying to code A ZDoom Frontend but i'm stumbling upon problems with getting the filename for the PWAD's that people might want to use in the command line. here's the little bit of code that's the problem:
Code:
********Dim WAD As System.Type ********If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then ************TextBox3 = WAD(OpenFileDialog1.OpenFile()) ********End If "Class 'System.Type' cannot be indexed because it has no default property." now i'm not sure why this is happening but please keep in mind that i've only just started learning how to code and i'm managing to get my head around the logic behind most of what i have seen so far but i can't figure some things out.
__________________
~Ceramic White PSP Status~ FW: 5.00 M33-6 Memory Stick: 8gb |
||
|
|
21-04-2007, 06:23 PM | #2 | ||
Join Date: Feb 2007
Location: Peterlee, England
Posts: 169
|
<div class='quotetop'>QUOTE(JJXB @ Apr 20 2007, 04:39 AM) [snapback]287605[/snapback]</div>
Quote:
Dim WAD As System.Type as stated my VB is a 'bit' lousy at times but will a string variable type not do for that value? , i'm not really sure what you are trying to define this as so appologies if this is totally incorrect!!!! |
||
|
|
22-04-2007, 12:02 PM | #3 | ||
Join Date: Oct 2004
Location: Godmanchester, England
Posts: 850
|
setting it as a string gives me a different error completely, i'm not in VB at the sec so i can't tell you it at the sec
__________________
~Ceramic White PSP Status~ FW: 5.00 M33-6 Memory Stick: 8gb |
||
|
|
22-04-2007, 03:46 PM | #4 | ||
Join Date: Dec 2004
Location: Eindhoven, Netherlands
Posts: 1,508
|
Use the following code (I'm a C# guy, so I'm not sure if the VB syntax is correct... I more or less HATE VB syntax :P):
Code:
Dim openFileDialog1 as OpenFileDialog If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then ******TextBox3.Text = Path.GetFileName( openFileDialog1.FileName ) Your code tried to do quite a lot of other things. By leaving out the .Text, you're trying to set the TextBox object directly instead of its Text property. And, what you think an object of type Type is exactly? |
||
|
|
23-04-2007, 01:26 PM | #5 | ||
Join Date: Oct 2004
Location: Godmanchester, England
Posts: 850
|
i've looked at the code and tried adapting it so it now looks like this (the full block of code now, not just the problem bit)
Code:
********Dim OpenFileDialog1 As New OpenFileDialog() ********OpenFileDialog1.Filter = "Wad Files|*.WAD" ********OpenFileDialog1.Title = "Select The WAD You Wish To Add" ******** ********Dim TextBox3 As TextBox ********If OpenFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then ************TextBox3.Text = Path.GetFileName(OpenFileDialog1.FileName) ********End If Quote:
__________________
~Ceramic White PSP Status~ FW: 5.00 M33-6 Memory Stick: 8gb |
||
|
|
23-04-2007, 01:34 PM | #6 | ||
Join Date: Dec 2004
Location: Eindhoven, Netherlands
Posts: 1,508
|
Mm... I copied this more or less from my C# file, which compiled and ran without errors... Did you add the System.IO namespace to you Imports?
The thing is, that you never have to declare Path, since its a Static class and can't be instantiated... |
||
|
|
23-04-2007, 07:12 PM | #7 | ||
Join Date: Feb 2007
Location: Peterlee, England
Posts: 169
|
I have used this and it seems to work but it gives the full filepath and the only way I could chop it up was a very awkward use of mid!
Code:
**OpenFileDialog1.Filter = "Wad Files|*.WAD" ********OpenFileDialog1.Title = "Select The WAD You Wish To Add" ********Dim WAD As String ********If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then ************WAD = (OpenFileDialog1.FileName) |
||
|
|
24-04-2007, 06:30 AM | #8 | ||
Join Date: Dec 2004
Location: Eindhoven, Netherlands
Posts: 1,508
|
That's what the Path-class takes care of. You know Path.GetFileName of Path.GetFileNameWithoutExtension etc. Check out the full range @ http://msdn2.microsoft.com/en-us/library/s...ers(vs.71).aspx
(this is .NET 1.1 version, since I don't know against which framework you're programming). |
||
|
|
24-04-2007, 07:10 PM | #9 | ||
Join Date: Feb 2007
Location: Peterlee, England
Posts: 169
|
<div class='quotetop'>QUOTE(Reup @ Apr 24 2007, 07:30 AM) [snapback]288251[/snapback]</div>
Quote:
doh!, i have never really used VB to this level but finally managed a working code, although it is not quite as yours seems to be it seems to work - (Visual Basic Express 2005 ) Code:
Dim WAD As System.IO.FileInfo OpenFileDialog1.Filter = "Wad Files|*.*" ********OpenFileDialog1.Title = "Select The WAD You Wish To Add" ********If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then ************WAD = My.Computer.FileSystem.GetFileInfo(OpenFileDialog1.FileName) ************MsgBox(WAD.Name) ************MsgBox(WAD.DirectoryName) |
||
|
|
01-05-2007, 10:46 PM | #10 | ||
Join Date: Oct 2004
Location: Godmanchester, England
Posts: 850
|
just got round to trying it and it works a treat plus i adapted the code to
Code:
Dim WAD As System.IO.FileInfo OpenFileDialog1.Filter = "PWAD Files|*.WAD" ********OpenFileDialog1.Title = "Select The WAD You Wish To Add" ********If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then ************WAD = My.Computer.FileSystem.GetFileInfo(OpenFileDialog1.FileName) ************TextBox1.Text = WAD.Name End IF
__________________
~Ceramic White PSP Status~ FW: 5.00 M33-6 Memory Stick: 8gb |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
A slight (resolution-related) DOSBox problem. | Simoneer | Tech Corner | 13 | 31-05-2009 03:53 PM |
Slight Delay When I Run Cd-rom Games, Why? | Razors78 | Troubleshooting | 8 | 31-05-2007 03:58 PM |
Slight Problem. Please help.ASAP!!!! | Anonymous | Troubleshooting | 5 | 17-07-2004 01:36 PM |
|
|
||
  |