|
cavemen wrote: i am using visual basic 6
so vb.net is no good for me
they are different languages
Well, welcome to reality. VB6 is crap, it always was, but now, it's unsupported crap. VB.NET is free. What possible reason could you have to use VB6 ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
vb6 is user friendly
no memory allocation, headers and all that bull$#!+, friendly syntax
plus this is the only compiler that i have
I cannot program VB.net, I am not a professional programmer to learn new languages every year.
I am just asking if you remember how to solve this issue using the methods of VB6.
Thanks.
|
|
|
|
|
Well, you better pick up VB.NET and fast. VB6 is not supported under Windows Seven. Once you do learn it, you'll find that VB6 is NOT user friendly in the least and you'll feel like you've been writing code in the Dark Ages.
|
|
|
|
|
Thank you for your advise but I am trying to solve a real problem with whatever technology available.
|
|
|
|
|
cavemen wrote: I am trying to solve a real problem with whatever technology available.
Visual Studio 2008 Express Edition is free and can be downloaded from the internet, without having to register or anything. Technology can't be much more available than that.
You don't need to be concerned about vb.net's syntax being a whole lot different from VB6's. The biggest difference is, that a lot things have been simplified. Certain things that would take you 5 lines of code in vb6, can be accomplished with a single method in vb.net. And if you can't figure out how to do something in vb.net, that you do know how to do in vb6, you can reference vb6 in vb.net and then still use the old functions after all.
Now more to the point of your problem, vb6 is not only no longer supported by MickeySoft, but has also been all but abandoned by programmers. This means that you'll be much more likely to get help solving your problem in vb.net, than in vb6. Also you'll find many many more examples on the net, and possibly ready made drivers and libraries to help you.
Trust me, when I switched from vb6 to vb.net, I was very frustrated for all of a week (maybe a week and a half). After that I felt, like Dave so aptly put it, like I had been writing code in the dark ages.
Save yourself a month of frustration in vb6 (and still not find the solution to your problem), by suffering a week and a half in vb.net.
My advice is free, and you may get what you paid for.
|
|
|
|
|
cavemen wrote: Thank you for your advise but I am trying to solve a real problem with whatever technology available.
You are trying to solve a real problem with inappropriate technology.
Choice of language apart, using a USB mic through a sound card in a PC will not give you any kind of accurate measurement of volume. (It's even debatable what you might mean by "volume" anyway...)
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Like the quote
To my shame I must say it actually took me a second look to get it.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Is there any way possible in a windows application project to kill the default current thread of the project and run a new thread and then relate the project to it?
My case scenario:-
I have a startup form. In its Load event I want to kill the current thread, create a new thread and run the project through the new thread. This'll be applicable in closing the startup form and open another form. When I run, the new thread is being created, everything is ok. But as soon as the default/current thread is being killed the application is closing down. How can I tackle this? Provided, I don't want to hide the startup form or stuffs like that.
Plz help. Regards.
|
|
|
|
|
i think there's other options but i'll give you want you ask for.
you would need to start a second message loop. so in the routine that's called when you start the new thread. do an application.run(your main form) in there. then close your startup form and the first message loop will killed.
'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: i think there's other options but i'll give you want you ask for.
you would need to start a second message loop. so in the routine that's called when you start the new thread. do an application.run(your main form) in there. then close your startup form and the first message loop will killed.
Hi nlarson11, I did it ur way. It works great. But i tried to change it a bit. Here's my code:
Imports System.Threading
Public Class frmStartup
Private Sub frmStartup_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim OldThread As Thread
Dim NewThread As Thread
Try
OldThread = Thread.CurrentThread
NewThread = New Thread(AddressOf NewThreadMethod)
NewThread.Start()
OldThread.Abort()
'Me.Close()
Catch tae as ThreadAbortException
'Do nothing.
Catch ex As Exception
MsgBox(ex.Message, , "frmStartup_Load")
End Try
End Sub
Private Sub NewThreadMethod()
Try
Application.Run(New frmAnother)
Catch ex As Exception
MsgBox(ex.Message, , "NewThreadMethod")
End Try
End Sub
End Class
U told me to close the startup form after starting the new thread. When I do that everything is fine. But instead, as I tried to terminate the old thread explicitly, When I run it from the IDE it seems to be ok but when I execute the app by clicking the exe only, it throws ThreadAbortException though I'm catching it. The problem stays even if I uncomment Me.Close() and use it with OldThread.Abort(). So is it mandatory that I'm limited to close frmStartup only and can't terminate the old thread explicitly without the exception being thrown? Looking 4ward 4 ur further advice. Thanks 4 ur help.
|
|
|
|
|
priyamtheone wrote: But as soon as the default/current thread is being killed the application is closing down. How can I tackle this?
Of course. The app's message pump is running in it, which you can't move to another thread.
Are you tryingt o do something like a Login form? Showing the login form, then starting your real main form??
|
|
|
|
|
That's correct u can assume it as a login form or a splash form. First I'll show it and then I want to show the main form. Here's a brief summary:
As we have seen, if u try to treat a startup
form as a splash form and try to close it and
goto the 2nd form the application closes down.
If u try to do this by writing the following
code in the startup form:
Application.Run(frm2ndForm);
this.Close();
It'll give an error message something like
'More than one message cann't be
passed/processed through a single thread. Try
using frm2ndForm.ShowDialog();'. Keeping this
in mind I'm trying to close the initial thread
in which frmStartup is running, create and run
a new thread and then open frm2ndForm from it.
Hope u understand. Looking forward 4 ur reply.
Thanx.
N.B.- nlarson11's answer is pretty close to what I want.
|
|
|
|
|
I have a clarification to finish this task. When I send from my computer ie. dave@hiscompany.com
password: dave working fine.
Same program when I tested with other system, but same login,same password,same domain [dave@hiscompany.com & only computer name different] it's not working.......any ideas to solve this problem...?
Really what I planned, to use 1-user name & Password, for this purpose with all machines...
is it possible?
I mean, the user login will be different, from the program I want to supply another user network credentials...Is it possible?
Anybody can show me the code?
Thanks
|
|
|
|
|
is the other computer on the same network?
does the other computer have access to the same smtp server the first computer did?
is the other computer blocking port 25?
'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
|
|
|
|
|
yah, same network under same domain. But it's a laptop, that machine is desktop.No other difference.
Even I tried the same user id,password. with same lan. May be laptop port no will be different?
How to identify that?
Thanks...
|
|
|
|
|
port no 25 is for SMTP only, check in your laptop is this port is blocked by any firwall or antivirus softwares.
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
Hi all,
I'm new into the forum and I have a question for you. How can I use the Win API 'SetParent' under VB 2008 to open a secondary form into a picturebox on a primary form? I need this because I want simulate a MDI form. For VB6 I used the following code and It works fine:
'<<declaration>>
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
'<<function>>
Public Function SetParentInRect(FormChild As Variant, FormParent As Variant)
On Error GoTo ErrorHandler
Dim lChild As Long
Dim lParent As Long
On Error Resume Next
If IsObject(FormChild) Then
lChild = CallByName(FormChild, "hwnd", VbGet)
If lChild = 0 Then Err.Raise 1000, , "Cannot obtain handle from formchild"
Else
lChild = CLng(FormChild)
End If
If IsObject(FormParent) Then
lParent = CallByName(FormParent, "hwnd", VbGet)
If lParent = 0 Then Err.Raise 1000, , "Cannot obtain handle from formparent"
If TypeName(FormParent) = "MdiMain" Then
lParent = FindWindowEx(lParent, 0&, "MDIClient", vbNullString)
End If
If TypeName(FormParent) = "frmMain" Then
lParent = FormParent.picContainer.hWnd
End If
Else
lParent = CLng(FormParent)
End If
If Not IsWindow(lChild) Then Err.Raise 1000, , "Invalid form Handle : " & lChild
If Not IsWindow(lParent) Then Err.Raise 1000, , "Invalid form Handle : " & lParent
SetParent lChild, lParent
If False Then
ErrorHandler:
Err.Raise Err.Number, IIf(Len(Err.Source) > 0, Err.Source & "->", "") & "clsParent", Err.Description
End If
End Function
The sencondary form have the follwing property:
startupposition = manual
borderstyle = none
windowsstate = maximized
Is there anyone can help me (to translate this function in VB 2008)?
Thanks a lot,
Filippo
|
|
|
|
|
something like this?
PictureBox1.Controls.Add(New Form2 With {.TopLevel = False, .Visible = True, .Dock = DockStyle.Fill})
'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
|
|
|
|
|
Yes! It works exactly as I need.
Thank you wery much for you suggestion!
Filippo
|
|
|
|
|
Readonly with Editor is not working as readonly after setting the image and it is working as readonly but not setting the iMage to picture
<[ReadOnly](True)> <Editor(GetType(ImageOpenFileDialog), GetType(System.Drawing.Design.UITypeEditor))> _
Public Property BackgroundPicture() As String
Public Class ImageOpenFileDialog
Inherits UITypeEditor
Dim openFileDialog As OpenFileDialog
Public Overrides Function EditValue(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal provider As System.IServiceProvider, ByVal value As Object) As Object
openFileDialog = New OpenFileDialog()
openFileDialog.FileName = ""
openFileDialog.Filter = "JPEG Images|*.jpg|GIF Images|*.gif|Bitmaps|*.bmp"
openFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyPictures
If openFileDialog.ShowDialog() = DialogResult.OK Then
Return openFileDialog.FileName
End If
Return MyBase.EditValue(context, provider, value)
End Function
Public Overrides Function GetEditStyle(ByVal context As System.ComponentModel.ITypeDescriptorContext) As System.Drawing.Design.UITypeEditorEditStyle
Return UITypeEditorEditStyle.Modal
End Function
End Class
I am creating a readonly Property and if i click i open the Images to select the image . as it is a readonly property i am not able to set teh image to picture box .
----------
Working on Visual Studio 2005 PropertyGrid .
I want to lock all the keys not to enter in the propertygrid at the Picture Property like in Visual Basic 6.0 after selecting the image . Only Delete has to work
PictureBox -- Picture Property -- (Bitmap) after setting the image
so that the user shouldnot change the value
Presently i got the (None) in this way . Now i want to set the ReadOnly and only Delete key has to work and i want to set the Picture to PictureBox.
|
|
|
|
|
Hi,
While trying to create a group of tables in msaccess using VB.NET ADOX, i am facing the error "System.Runtime.InteropServices.COMException...at ADOX.columns.Append(Object item, DatatypeEnum Type, Int32 DefinedSize)".
The coding is given below..
Public Function CreateAccessDatabaseandtables( _
ByVal DatabaseFullPath As String) As Boolean
Dim bAns As Boolean
Dim con As New ADODB.Connection
Dim cat As New ADOX.Catalog()
Dim ADOXtable As New ADOX.Table
Dim ADOXindex As New ADOX.Index
Try
Dim sCreateString As String
sCreateString = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
DatabaseFullPath
cat.Create(sCreateString)
bAns = True
'cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DatabaseFullPath
con.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DatabaseFullPath)
'name table, append fields to table
ADOXtable.Name = "ACN_CHARX"
ADOXtable.Columns.Append("LOGICAL_DB_NAME", ADOX.DataTypeEnum.adVarWChar, 32)
ADOXtable.Columns.Append("DIM_NAME", ADOX.DataTypeEnum.adVarWChar, 32)
ADOXtable.Columns.Append("CHARX_NAME", ADOX.DataTypeEnum.adVarWChar, 128)
ADOXtable.Columns.Append("CHARX_SEQ", ADOX.DataTypeEnum.adInteger)
ADOXtable.Columns.Append("CHARX_TYPE", ADOX.DataTypeEnum.adVarWChar, 1)
ADOXtable.Columns.Append("BITMAP", ADOX.DataTypeEnum.adInteger)
'append tables to database
cat.Tables.Append(ADOXtable)
ADOXtable.Name = "ACN_CHARX_INSTANCE"
ADOXtable.Columns.Append("LOGICAL_DB_NAME", ADOX.DataTypeEnum.adVarWChar, 32)
ADOXtable.Columns.Append("DIM_NAME", ADOX.DataTypeEnum.adVarWChar, 32)
ADOXtable.Columns.Append("CHARX_NAME", ADOX.DataTypeEnum.adVarWChar, 128)
ADOXtable.Columns.Append("CHARX_TABLE", ADOX.DataTypeEnum.adVarWChar, 128)
ADOXtable.Columns.Append("CHARX_VALUE_COL", ADOX.DataTypeEnum.adVarWChar, 128)
ADOXtable.Columns.Append("VALUES_UNIQUE", ADOX.DataTypeEnum.adInteger)
ADOXtable.Columns.Append("CHARX_ORDER_COL", ADOX.DataTypeEnum.adVarWChar, 128)
ADOXtable.Columns.Append("CHARX_ORDER", ADOX.DataTypeEnum.adInteger)
ADOXtable.Columns.Append("CHARX_NUMERIC_COL", ADOX.DataTypeEnum.adVarWChar, 128)
ADOXtable.Columns.Append("BITMAP_COL", ADOX.DataTypeEnum.adVarWChar, 128)
'append tables to database
cat.Tables.Append(ADOXtable)
Catch Excep As System.Runtime.InteropServices.COMException
bAns = False
MessageBox.Show(Excep.ToString)
Finally
cat = Nothing
End Try
Return bAns
End Function
Please help me to rectify this error...
Thanks,
Sivakumar.M.
modified on Wednesday, June 17, 2009 6:45 AM
|
|
|
|
|
Does the exception tell which line of code exactly is throwing the error?
My advice is free, and you may get what you paid for.
|
|
|
|
|
No...Actually the first table "ACN_CHARX" is created successfully... when it crosses the line "ADOXtable.Name = "ACN_CHARX_INSTANCE" ", the first created table name is automatically renamed.. ie)from "ACN_CHARX" into "ACN_CHARX_INSTANCE". Then the control tried to create the first column of the second table "Logical_db_name"...Then it shows this error....
|
|
|
|
|
I expect you need to add
ADOXtable = New ADOX.Table
between each table. Probably the same for the index.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Thanks for your nice solution....Now it is working fine....In addition with this, could you please mention how to add constraints with table columns through coding?
|
|
|
|
|