|
ok see this, the items on the Combobox will not be edited.
comboBox1.Items.Add("First");
comboBox1.Items.Add("Second");
comboBox1.Items.Add("Third");
comboBox1.Items.Add("Forth");
comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
Hope this is what you want
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Set its DropDownStyle property to DropDownList.
|
|
|
|
|
Hi friends,
I have an interesting problem in vb.net. And I am struggling to get a solution for this..m trying for the past 3days.. It’s to calculate moving average for the inputs given by the user..
The following are the steps..
1, get 2user inputs in textbox(1st input is number is periods, 2nd is moving range)
2, after getting both the user inputs, the user will click on an input button which must dynamically generate rows for the number of periods given by the user as well as a calculate button must appear dynamically.
3, the user again inputs the values for all the dynamically generated rows and when by pressing calculate button, the moving average for the given moving range must appear in another column
Im half way through and I have attached my progress here.. I would greatly appreciate if u complete it for me.. thanks in advance
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim TxtDyn1 As TextBox()
Dim TxtDyn2 As TextBox()
Dim TxtDyn3 As TextBox()
Dim TxtDyn4 As TextBox()
Dim numofper As Integer
Try
'to check the textbox for empty
If Not TextBox1.Text Is String.Empty Then
numofper = TextBox1.Text
ReDim TxtDyn1(numofper)
ReDim TxtDyn2(numofper)
ReDim TxtDyn3(numofper)
ReDim TxtDyn4(numofper)
Else
Exit Sub
End If
'To create the dynamic text box and add the controls to panel
For i As Integer = 0 To numofper - 1
TxtDyn1(i) = New TextBox
Panel1.Controls.Add(TxtDyn1(i))
Next
For j As Integer = 0 To numofper - 1
TxtDyn2(j) = New TextBox
Panel2.Controls.Add(TxtDyn2(j))
Next
For k As Integer = 0 To numofper - 1
TxtDyn3(k) = New TextBox
Panel3.Controls.Add(TxtDyn3(k))
Next
For l As Integer = 0 To numofper - 1
TxtDyn4(l) = New TextBox
Panel4.Controls.Add(TxtDyn4(l))
Next
Dim mybutton As New Button (THIS S NOT WORKING )
mybutton.Text = "button 2"
AddHandler mybutton.Click, AddressOf button2.click
Me.Controls.Add(mybutton)
Catch ex As Exception
MsgBox("Enter a valid Number")
End Try
End Sub
End Class
|
|
|
|
|
You've done nothing but create arrays of controls. There is no code to generate any moving average or anything else. You're missing the meat of the application. Forget about the User Interface stuff for now and create the code to generate the data you need. This is going to need some kind of input to do and this need to going to dictate how you do the UI. You may even end up scraping everything you have so far to do this.
|
|
|
|
|
hi .. i am new to vb.net and i have a problem in maintaining values in two button events.. so pls help me.. i have just added some code to that.. please correct them and help me completing.. im struggling without enough source to refer..
Partial Public Class _Default
Inherits System.Web.UI.Page
Dim textdynamic1 As New ArrayList()
Dim textdynamic2 As New ArrayList()
Dim textdynamic3 As New ArrayList()
Dim textdynamic4 As New ArrayList()
Dim TxtDyn1 As TextBox()
Dim TxtDyn2 As TextBox()
Dim TxtDyn3 As TextBox()
Dim TxtDyn4 As TextBox()
Dim k As Integer
Dim a As Integer
Dim b As Integer
Dim l As Integer
Dim numofper As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
'to check the textbox for empty
If Not TextBox1.Text Is String.Empty Then
numofper = TextBox1.Text
ReDim TxtDyn1(numofper)
ReDim TxtDyn2(numofper)
ReDim TxtDyn3(numofper)
ReDim TxtDyn4(numofper)
Else
Exit Sub
End If
'To create the dynamic text box and add the controls to panel
For i As Integer = 0 To numofper - 1
TxtDyn1(i) = New TextBox
Panel1.Controls.Add(TxtDyn1(i))
textdynamic1.Add(textdynamic1)
Next
For j As Integer = 0 To numofper - 1
TxtDyn2(j) = New TextBox
Panel2.Controls.Add(TxtDyn2(j))
textdynamic2.Add(textdynamic2)
Next
For k As Integer = 0 To numofper - 1
TxtDyn3(k) = New TextBox
Panel3.Controls.Add(TxtDyn3(k))
textdynamic3.Add(textdynamic3)
Next
For l As Integer = 0 To numofper - 1
TxtDyn4(l) = New TextBox
Panel4.Controls.Add(TxtDyn4(l))
textdynamic4.Add(textdynamic4)
TxtDyn4(l).Enabled = False
Next
Catch ex As Exception
MsgBox("Enter a valid Number")
End Try
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
Dim nval As Integer
nval = TextBox2.Text
For Each b As Integer In textdynamic4
Do
For Each a As Integer In textdynamic3
a += TxtDyn3(k).Text
Next
Loop While k <= nval
TxtDyn4(l).Text = a / nval
Next
End Sub
End Class
|
|
|
|
|
Please help me to disable / hide Start Orb in Windows Vista using Visual Basic 6 (not VB.Net, VB2005 or VB2008 or C# or C++ !!!).
Such solution on this website was proposed by Simon B. using VB2008, however I need it for Visual Basic 6.
Thanks in advance for your help.
|
|
|
|
|
Hiding the Taskbar and Startmenu (start orb) in Windows Vista[^]
Now before you complain that that code is C#, the APIs are all the same. All you have to do is use the API viewer to convert it to VB6. Should be a piece of cake to do. I don't know if that's the article you referenced or not, because that one is not VB.
Someone on here[^], suggested the following line: ShowWindow(FindWindowEx(NULL, NULL, MAKEINTATOM(0xC017), NULL), SW_HIDE); Again, you can easily do that in VB because it's just two basic API calls.
|
|
|
|
|
Hello,
Does anyone know how to use a Function Delegate? I have used many Sub Delegates but the function escapes me....
Here's my Code...why does this not work?
Public Delegate Function FormsUIThread(ByVal oFrm As Form) As Form
Public Shared Function GetOnFormsUIThread(ByVal oFrm As Form) As Form
If oFrm Is Nothing Then Return Nothing
If oFrm.InvokeRequired Then Return oFrm.Invoke(New FormsUIThread(AddressOf GetOnFormsUIThread), oFrm)
Return oFrm
End Function
Thanks
Nathan
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
What do you mean by "it doesn't work"? Does it compile? throw an exception? Return an unexpected result? ...
|
|
|
|
|
Sorry for leaving that out...it says I'm still in violation of cross-threading. The invoke should of got me on the forms thread but it is not working.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
nlarson11 wrote: The invoke should of got me on the forms thread
The Invoke does execute in the UI thread, but that is totally pointless as all you are doing is returning a reference to the form. The reference doesn't get any different from being returned from another thread, and when you use the reference, you are still using it from your thread.
It's whatever you do with the form that you need to call using Invoke.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Nathan,
Following is a demo of Funtion Delegates in VB.Net
BEGIN CODE
Imports System
Public Class MainClass
Dim emp As New Employee("First Name", "Last Name")
Private Delegate Function NumEmployeesDelegate() As Integer
Shared Sub Main(ByVal args As String())
Dim show_num As NumEmployeesDelegate
show_num = AddressOf Employee.GetNumEmployees
Console.WriteLine(show_num().ToString)
End Sub
End Class
Public Class Employee
Private m_FirstName As String
Private m_LastName As String
Private Shared m_NumEmployees As Integer = 0
Public Shared Function GetNumEmployees() As Integer
Return m_NumEmployees
End Function
Public Sub New(ByVal first_name As String, ByVal last_name As String)
m_FirstName = first_name
m_LastName = last_name
m_NumEmployees += 1
End Sub
Public Overrides Function ToString() As String
Return m_FirstName & " " & m_LastName
End Function
Private disposedValue As Boolean = False ' To detect redundant calls
End Class
END CODE
Hope thhis helps
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hey John,
Thank you. I need an example that deals with a Forms UI thread where I have to test if an invoke is required and invoke to get on that form's thread. I know i can do this with a Sub Delegate but the Function Delegate I can't?
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Is the error happening inside this function or after the function call when you use the value returned from it?
If it is the latter, than the problem is that the call to Invoke only makes GetOnFormsUIThread be on the main thread. The function that called it originally is still on a different thread and any access to the members of the form returned from the function will continue to throw an exception.
|
|
|
|
|
I'm trying to create a custom control with on it a label and textbox (for now)
I want to be able to set the properties of these controls at design time, but when I do this they keep being reverted back to there initial settings (at run time).
Any ideas on how to solve this?
|
|
|
|
|
a 'user control' will do what you want.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
not really
I have a 'user control' with on it a label and a textbox
I want to be able to set the properties off the label and textbox at design time (I can do this but when I run the test project the properties are reset to there original value's)
|
|
|
|
|
You'll have to write code to re-expose those properties yourself. You don't make the Label and TextBox controls public. You keep them private, then expose just the properties you want. For example, in your UserControl code, you can expose the Text Property of it's constituant Lable control like this:
Public Property LabelText() As String
Get
Return MyLabelControl.Text
End Get
Set(ByVal value As String)
MyLabelControl.Text = value
End Set
End Property
|
|
|
|
|
So there is no way to expose them all (except doing making a property myself for all of them)
Ok thank you for the help, I guess I'm off to writing properties now
|
|
|
|
|
I have a VB.Net COM dll that I created and installed (using regasm) on a server. On this server is an application that calls different code modules based on events. One of those code modules calls the com dll which fires off and does a few things. If this process is kicked off from the server, everything works just fine. However, when the application is run from a workstation, the COM call fails. The workstation calls the code modules that reside on the server, the same ones that the server uses.
So why would the call to the COM object work fine on the Server, but when called through a workstation, to the server, fails out?
The CreateObject statement that creates the com object does not fail, but when called through the workstation, the call to the COM method fails.
Here's an example:
foo = CreateObject("Obj.Class")
result = foo.callMethod
The CreateObject works fine, but the foo.callMethod fails when it is kicked off from a workstation.
Anyone run into something like this before?
|
|
|
|
|
if you have brought that object to the PC then everything it talks that it talked to on the server also needs to be on the PC (excluding http and sql server calls). It will not execute code on the server.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
Sorry, I may not have explained well enough. It's setup like this: The server hosts the main application. Workstations have a satellite application that calls the main one to do most of the processing. The code that calls the COM object resides on the server. So everytime the server's main application is called, it will fire off the COM object. If the code to fire that COM object is called from the server itself, then it runs fine. But, if the satellite application calls the main application on the server, then it errors out.
|
|
|
|
|
How can I call functions from a "normal" (just plain old C) DLL from my VB.NET program? Also, is it possible to get a list of functions that are exported by the DLL?
|
|
|
|
|
There's a good bit of sample code out there, like this article.[^]. As for listing the functions, I don't think you can, but I don't always know everything.
|
|
|
|
|
I'm teaching myself vb.net again after being out of school for a few years. My problem is probably simple although I don't know the correct terminology so it makes it hard to search for a solution. I am making a simple game with picture boxes. I created the variable YellowDrop which is a string. It concatenates a few things to create "Yellow6x1" for example. This is a picture box. I now need the command equivalent to yellow6x1.visible. I cannot just do yellowdrop.visible because visible is not a part of string. Can someone point me in the correct direction? Thank you.
If cbColor.Text = "Yellow" Then
For RowLoop = 6 To txtRow.Text Step -1
YellowDrop = ("Yellow" & (RowLoop) & "x" & (txtColumn.Text))
'****Here is where I need a command that would act like YellowDrop.visible****
Next
End If
modified on Friday, October 3, 2008 10:48 AM
|
|
|
|