|
How do I check if a folder already exists on the system without including any classes in my code?
I dont know why the Try-Catch block does not work in my code. It gives compilation error that try is not excepted
|
|
|
|
|
if (System.IO.Folder.Exists(
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
First, what version of VB are you using? Second, what does you code look like?? Without that, it's really hard to tell you what you did wrong.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Heah thanx, I got the thing working with the following piece of code
Dim folderPath As String
Dim fs
folderPath = "C:\test"
Set fs = CreateObject("Scripting.FileSystemObject")
If (fs.folderexists(folderPath) <> True) Then
MsgBox "Folder does not Exist"
Else
MsgBox "Folder Exists"
End If
|
|
|
|
|
Is there a best practices guideline for creating forms that are least likely to look different across deployment (that is, with users using different display sizes, fonts, font sizes, etc.)?
Thanks
|
|
|
|
|
less is more
My advice is free, and you may get what you paid for.
|
|
|
|
|
I have to write a program, in vb.net 05, that does some clean up. The desired time for the program to run is when the user logs off and the computer begins the shutdown process. I realize I could probably use "Scheduled Tasks" to run the program at log off/shut down, but I'd like to use the registry to execute the program at logoff/shutdown.
I've got the guts of the program already written, I just need to figure out how to write to the registry to run at logoff/shutdown. Any help is appreciated!!!
|
|
|
|
|
|
hi,
what is the exact keyword for vb.net Freind access modifier type in C# ??
Thanks,
Rahi
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
|
thanks! please let me know if any site which gives us basic syntactical/language differences between C# and VB.Net........
i appreciate ur help!
Thanks,
Rahi
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
|
Thanks very much......... i saw the articles. it's really good in this site (codeproject).
Thanks once again for the response,
Rahithi
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
All you have to do is look at thousands of code samples on MSDN. Most examples are in both languages, supplying you with quite a large Rosetta Stone to translate between the two.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Despite a signifigant amount of research I have yet to be able to crack this one: I Need to be able to adjust the amount of items displayed in the listbox of the combobox - i.e. sometimes 4, sometimes 24, sometimes in between. I've noticed the windows API has a CB_SETDROPPEDWIDTH - but cannot find an equivilant for height (CB_SETITEMHEIGHT sets individual item height - doesn't adjust the listbox size). If it cannot be done through API calls (and i'm beginning to think it can't) then how? If it needs to be painted I would appreciate a brief example if possible?
thanks much
|
|
|
|
|
ComboBox1.MaxDropDownItems should work in vb.net, in vb6 there is not a corresponding function, and in the api there is only a function to find out what the size and position of the dropdown CB_GETDROPPEDCONTROLRECT. You might look into creating a custom control in vb.net expose it to com and use it in your vb app.
Sorry I don't have anything more concrete, maybe someone else does.
|
|
|
|
|
Much Thanks - It is indeed a VB6 project. I suppose that means my only options are to create the vb.net control or to manually paint the control in VB6?
|
|
|
|
|
Thats what I think, someone else may have another idea though.
|
|
|
|
|
Hey everyone,
I've got a webpage that has a selfmade webusercontrol.
That webusercontrol dynamically creates (at this moment only) a label control, a calendar control and a textbox control, depending on how many items I give the control through a Session.
So far so good, for every item in Session a set of these controls is created and added to the page.
They display nicely.
*I hear the collective going "BUT?"*
Ah yes, there's a "but".
What I want to do, is fill the textbox of a set with the selected date of the calendar object of THAT set.
But there are (in this example) two calendar objects.
NOTE: (I have to add the calendar objects dynamically as I don't know how many date type parameters will be required in the near future)
How can I get the selectionchanged event from one of the calendar, so that the control "knows" it's from that calendar and fill the correct textbox that belongs to that calendar ?
Don't forget, all the controls are being generated at runtime in a webusercontrol, which means that somehow I have to create dynamic eventhandlers that "knows" which calendar object had the selectionchanged event and "knows" which which textbox object to set the text of.
Code in VB.NET please, not ASP.NET.
Everything is being done in the code behind, which is VB.NET.
Some help would be greatly appreciated.
|
|
|
|
|
Create your calender control using withevents, create a sub with the same signature as the selection changed event, use addhandler controlname.eventname, addressof yourEvent
|
|
|
|
|
If I use a withevents declaration, I end up with only one calendar on the resulting page.
Seems as though it overwrites the first one.
Perhaps because it uses a global identifier within the control instead of one contained in a sub?
|
|
|
|
|
You don't need withevents to add an event handler at runtime. Just declare it like you have been but add the handler as suggested when you create each control.
|
|
|
|
|
That works like a charm, except...
How do I set the dynamic txtCalendar.text if it's not globally declared?
How can I find the dynamicaly declared textbox and set the text value?
Code so far:
<br />
Public Class ListReportParametersControl<br />
Inherits System.Web.UI.UserControl<br />
<br />
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
Dim intCounter1 As Integer<br />
Dim strParamValue As String<br />
Dim arrSessionParams() As String = Session("ReportParams").ToString.Split(",")<br />
Dim arrTempTypeNValue() As String<br />
<br />
For intCounter1 = 0 To UBound(arrSessionParams)<br />
arrTempTypeNValue = arrSessionParams(intCounter1).ToString.Split(":")<br />
Select Case arrTempTypeNValue(0)<br />
Case "CALENDAR"<br />
SetCalendar(arrTempTypeNValue(1))<br />
ReDim Preserve arrControls(intCounter1)<br />
arrControls(intCounter1) = arrTempTypeNValue(1).ToString<br />
End Select<br />
Next<br />
End Sub<br />
<br />
<br />
Public Sub SetCalendar(ByVal CalendarID As String)<br />
Dim lblCalendar As New Label<br />
lblCalendar.Font.Name = "Verdana"<br />
lblCalendar.Font.Size = FontUnit.Parse("10")<br />
lblCalendar.ID = "Label" & CalendarID<br />
lblCalendar.Text = CalendarID<br />
<br />
Dim myCalendar As New Calendar<br />
myCalendar.Font.Name = "Verdana"<br />
myCalendar.Font.Size = FontUnit.Parse("10")<br />
myCalendar.ID = CalendarID<br />
myCalendar.EnableViewState = True<br />
myCalendar.TodaysDate = System.DateTime.Today<br />
myCalendar.VisibleDate = System.DateTime.Today<br />
myCalendar.TitleFormat = TitleFormat.MonthYear<br />
myCalendar.SelectionMode = CalendarSelectionMode.Day<br />
myCalendar.NextPrevFormat = NextPrevFormat.CustomText<br />
myCalendar.TodayDayStyle.BackColor = System.Drawing.Color.Red<br />
myCalendar.OtherMonthDayStyle.BackColor = System.Drawing.Color.FromName("LightGray")<br />
AddHandler myCalendar.SelectionChanged, AddressOf myCalendarSelectionChanged<br />
<br />
Dim txtCalendar As New TextBox<br />
txtCalendar.Font.Name = "Verdana"<br />
txtCalendar.Font.Size = FontUnit.Parse("10")<br />
txtCalendar.ID = "Textbox" & CalendarID<br />
'txtCalendar.Text = myCalendar.UniqueID.ToString<br />
<br />
Me.Controls.Add(lblCalendar)<br />
Me.Controls.Add(myCalendar)<br />
Me.Controls.Add(txtCalendar)<br />
End Sub<br />
<br />
Public Sub myCalendarSelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)<br />
'Does nothing, yet.<br />
Dim strSenderID As String<br />
Dim strSenderType As String<br />
<br />
strSenderType = UCase(sender.GetType.Name)<br />
strSenderID = sender.ID<br />
<br />
Select Case strSenderType<br />
Case "CALENDAR"<br />
<br />
End Select<br />
<br />
End Sub<br />
<br />
End Class<br />
What do I put in the Case "CALENDAR" ?
It doesn't know txtCalendar...
Any suggestions?
|
|
|
|
|
The quickest fix I can think of is a hashtable. Use the calander object as the key and the textbox will be the value. Declare the hashtable globally and when you create a new 'control group' add the new value.
'Declare globally
dim hash as new hashtable
'In the SetCalander method
hash.add(myCalendar, txtCalendar)
'In the selectionchange event
'This will give you a reference to the appropriate textbox
dim txt as textbox = hash(sender) This should work. It may not be the best solution but it was the quickest fix I could think of.
|
|
|
|
|
You guys are AWESOME...
Total team effort.
I thank M-Hall and Twofaced for their assistance.
|
|
|
|