|
Dunno why but it doesn't work for me...
Check out this test:
<br />
Private Sub cmdTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTest.Click<br />
<br />
Dim ctest As ControlCollection<br />
ctest = Me.Controls<br />
<br />
End Sub<br />
This works.
<br />
Private Sub cmdTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTest.Click<br />
<br />
Dim ctest As ControlCollection<br />
ctest = tcMain.Controls 'tcMain is a TableControl object<br />
<br />
End Sub<br />
This doesn't, all I get here is a casting error.
Anyone know why?
/regards Joakim
|
|
|
|
|
That's weird, because that is a ControlCollection. Is that all your code ? What line blows up ? If you can give me some html, I can do a test here.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yeah I know, I made another test just to check that there was no other code in my program that was messing with this function.
So I made a fresh start, standard windows app. with a TabControl with 2 TabPages, then I added 2 TextBoxes and 1 Label to each TabPage, and a Button on the first TabPage. and then I added this code and get the same error.
<br />
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<br />
GetControls(Me.Controls)<br />
End Sub<br />
Public Function GetControls(ByVal cControl As ControlCollection)<br />
Dim iControls As Integer<br />
For i As Integer = 0 To cControl.Count - 1<br />
If TypeOf cControl(i) Is TabControl Then<br />
MsgBox(cControl(i).Name)<br />
GetControls(cControl(i).Controls)<br />
End If<br />
If TypeOf cControl(i) Is TabPage Then<br />
MsgBox(cControl(i).Name)<br />
GetControls(cControl(i).Controls)<br />
End If<br />
If TypeOf cControl(i) Is TextBox Then<br />
iControls += 1<br />
End If<br />
If TypeOf cControl(i) Is Label Then<br />
iControls += 1<br />
End If<br />
Next<br />
MsgBox(iControls)<br />
End Function<br />
No idea why it wont work, looks like TabControls don't use the same ControlCollection as for example TabPages or something like that.
Thing is that I like to make this function dynamic so I can use it in any situation to check for Controls in an ControlCollection.
Joakim .A - State: VB6 -> VB.NET
|
|
|
|
|
and here is a html with a rar on the testproject >WindowsApplication1.rar<
the line 165 crashes in this example, when it tries to call the function with a TabControls ControlCollection.
Joakim .A - State: VB6 -> VB.NET
|
|
|
|
|
You seem to be right - the TabPage AND TagControl have TabControl.ControlCollection and TabPage.ControlCollection collections, you need seperate functions to pass those objects to and iterate through. What a disaster.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I think you making it harder than you need to.
For each tabcontrol there are tabpages which contain the controls your trying to count.
Function CountControls(ByVal tPage As TabPage)
Dim count As Integer = 0
Dim c As Control
For Each c In tPage.Controls
If TypeOf (c) Is TextBox Then
count += 1
End If
Next
Return count
End Function
Simply pass in the tabpage you wish to count the controls on..
Debug.WriteLine("Total textboxes: " & CountControls(TabControl1.TabPages(0)))
Hope this helps.
|
|
|
|
|
Sould read... sorry
Function CountControls(ByVal tPage As TabPage) as integer
Dim count As Integer = 0
Dim c As Control
For Each c In tPage.Controls
If TypeOf (c) Is TextBox Then
count += 1
End If
Next
Return count
End Function
|
|
|
|
|
Aye, I have done that now, but I want to make this function more dynamic.
So I could pass Me.Controls to the function and get refs to all TextBoxes for example.
Joakim .A - State: VB6 -> VB.NET
|
|
|
|
|
How do I open a new child MDI form from an existing childmdi form?
I want the new child mdi form to open within the same parent.
Godwin
|
|
|
|
|
in the child form do this
Dim frm as new Form1
frm.mdiParent = Me.MdiParent
frm.show()
|
|
|
|
|
|
hii everybody..
my ASP .NET Web Application was working properly.. but suddenly one day all the code in javascript stopped working.. i m not able to find out the prob.. all the other data retrieval is working properly..
plzzz help if u can...
|
|
|
|
|
Is the browser running javascript ? Did you install XP SP2 ? That could be turning off jscript support in the browser. Although, the rest of ASP.NET relies of jscript - are you sure your scripts are being inserted into the pages still ? How do you insert them ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a windows form with an com component.This application works fine on local hard drive but when i acces my application from the network it gives system.security.securityexception:Request failed.What should i do
smita
|
|
|
|
|
I guess that you are trying to load the application after mapping the network drive (directly from server instead of installing). is it true ? if yes then remember that application will load in your system and in your system com component does not exist. So install it on your machine.
|
|
|
|
|
i am working with vb.net and want to create a random file. the file should not be fixed size......helpme .... ByVal e As System.EventArgs) Handles Button6.Click
Dim Employee As Person
FileNum = FreeFile()
FileOpen(FileNum, TextBox1.Text, OpenMode.Random, , , Len(Employee))
Do While Not EOF(FileNum)
FileGet(FileNum, Employee, )
If Employee.ID = Val(TextBox5.Text) Then
Position = Loc(FileNum)
TextBox5.Enabled = False
TextBox6.Enabled = True
TextBox7.Enabled = True
Button5.Enabled = True
Button6.Enabled = False
Button7.Enabled = True
TextBox6.Text = Employee.Name
TextBox7.Text = Employee.Surname
Exit Do
End If
Loop
FileClose(FileNum)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim Employee As Person
FileNum = FreeFile()
FileOpen(FileNum, TextBox1.Text, OpenMode.Random, , , Len(Employee))
Seek(FileNum, Position)
Employee.ID = Val(TextBox5.Text)
Employee.Name = TextBox6.Text
Employee.Surname = TextBox7.Text
FilePut(FileNum, Employee, )
FileClose(FileNum)
TextBox5.Enabled = True
TextBox6.Enabled = False
TextBox7.Enabled = False
Button5.Enabled = False
Button6.Enabled = True
Button7.Enabled = False
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim Employee As Person, FileNum1, FileNum2 As Integer
FileNum1 = FreeFile()
FileOpen(FileNum1, TextBox1.Text, OpenMode.Random, OpenAccess.Read, , Len(Employee))
FileNum2 = FreeFile()
FileOpen(FileNum2, "abcdefg.tnt", OpenMode.Random, OpenAccess.Write, , Len(Employee))
Do While Not EOF(FileNum1)
If (Loc(FileNum1) <> Position - 1) Then
FileGet(FileNum1, Employee, )
FilePut(FileNum2, Employee, )
Else
FileGet(FileNum1, Employee, )
End If
Loop
FileClose(FileNum1)
FileClose(FileNum2)
Kill(TextBox1.Text)
Rename("abcdefg.tnt", TextBox1.Text)
TextBox5.Enabled = True
TextBox6.Enabled = False
TextBox7.Enabled = False
Button5.Enabled = False
Button6.Enabled = True
Button7.Enabled = False
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
End Sub
End Class
after inserting few records in file ....new data is not being taken....
|
|
|
|
|
virtual_manu wrote:
i am working with vb.net and want to create a random file
doesn't mean anything for me...
what to you write inside your file ?
virtual_manu wrote:
the file should not be fixed size......
just write in it, it will increase its size ...
pssst, do you know what you're trying to do ?!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
make your question more clear and do not put the long code as 99% of the viewers do not have enough time to read and debug your code. So put your question again without code and explain it little more what you want. like creating text file and inserting values in it from text boxes or what ever is your requirement
or wait for the 1% guys if they found this code they might debug it for you.
|
|
|
|
|
i want to create a random file in vb.net ...where i can insert, update and search data ...help
|
|
|
|
|
well I guess you want to work in file system. as there is nothing in my vocabulary called "Random File" . I suggest you to use XML which is supported well by Dot net and is good according to your requirement
|
|
|
|
|
hello friends,
i have created a DLL using C# on .net plateform.
i want to use that DLL file in the VB6.0.
how can i do this?
how would i register that DLL without .net plateform, so that i can use that DLL in my project of VB6.0.
Please reply soon...
Gagan Deep Singla
Chandigarh - INDIA
|
|
|
|
|
If you created the dll on .NET platform, you will still need to have .net framework installed on the target machine. Here is a sample class that's exposed to COM. You will also need to register the dll with regasm.exe utility found in %windir%\microsoft.net\framework\v1.1.*.
You can use this library in vbscript or vb6 (or any other COM client) simply with:
Set demo = CreateObject("Demo.demo") 'notice the ProgId below
Here is a link with some more explanation: http://www.codeproject.com/dotnet/nettocom.asp?df=100&forumid=14076&exp=0&select=1028513[^]
Imports System.Runtime.InteropServices
Imports System.Text
<guid("e3928d8b-4eca-42c1-81cf-482f1c18b5f7"), interfacetype(cominterfacetype.interfaceisidispatch)=""> _
Public Interface _demo
<dispid(1)> Function GetString(ByVal strString As String) As String
End Interface
<guid("e601fd54-fa5b-4b62-a7ae-abbe701b8626"), _
classinterface(classinterfacetype.none),="" _
progid("demo.demo")=""> Public Class demo
Implements _demo
Public Function GetString(ByVal strString as String) As String Implements _demo.GetString
Return "COM Sample"
End Function
End Class
Enes M
|
|
|
|
|
Some parts of the class got stripped off when i submitted it (because of the < tag), so it won't work. But look at the link above, it has more in depth information.
|
|
|
|
|
Hi
When you want to write your class in C#, try adding a ComClass rather than a simple class. (the ComClass should be availabe in Project>AddNewItem if I remember correctly.
Then make your dll file, C# would register the class for you and then you can simply use your class on your machine using CreateObject.
(to use the class on an other machine, you must first use regasm.exe as told to you.)
Hope it was helpful.
|
|
|
|
|
I have been able to configure IIS thorugh VB.Net. But the problem is :
When I create a virtual directory it creates under "Default Web Site". How can i create a new virtual directory not under "Default Web Site".
I am not been able to assign the Application Name. The Aplication Name is blank. How can i set the application name
And
Not been able to set permission on the web site, only the default permission are set. How can i set permission on the web site
I am using System.DirectoryServices
I've been able to assign the Application Name
but when i try to set permission
VirDir.Properties("AccessWrite").Value = True
It gives me error
|
|
|
|