|
There are two ways you could try to do that. The first would be to declare all the controls on both child forms as Public. Then, you could access controls from the other form.
Your second option would be to create a module that would contain variables, and depending on the variables, the listview would update.
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
ive been wondering along time.
does anyone know how to use MIDI instruments, etc, to create notes for output to speakers, in VB.net?
it seems impossible, no one has said anything about it.
------------------------
Jordan.
III
|
|
|
|
|
Nadroj wrote:
it seems impossible, no one has said anything about it.
I'm sure someone knows how to do it, but not me. Have you tried searching MSDN or Google?
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
iv been searching online for quite a while then gave up. i can only find examples in vs.net for like c++, c#, not vb.net
anyways, thanks alot for your input!
------------------------
Jordan.
III
|
|
|
|
|
Nadroj wrote:
for like c++, c#, not vb.net
Use the C# stuff and convert it over. Should not be that hard.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Ray Cassick wrote:
Use the C# stuff and convert it over. Should not be that hard.
This is true. I never really learned C#, but I know JavaScript (the syntax is very similar).
All you have to remember when converting from C# to VB.Net, is that you declare the data type defore the variable.
Examples:
(dim i as integer) in VB.Net is (int i = 5) in C#
(sub hello(byval world as string)) in Vb.Net is (void hello(string world)) in C#.
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
Because I am a lazy programmer (there is an oxymoron right?) If the code is long and I am crunched for time I always start out with a quick conversion tool. It atleast gets me 90% there most of the time.
Try this one out[^]
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Yes, C# to VB.Net converters can usually convert a good amount of code decently. There are still some things that are not converted correctly (attaching events, single line if...then, etc.) but converters are a good time saver. Especially if you are a lazy programmer like Ray or me
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
Looking for code to pass information from Form2.textbox1 back to Form1.label1
Process - Press Form1.button1 to show Form2,
Enter information into Form2.textbox1,
Press Form2.button1 to display information from Form2.textbox1 to Form1.label1.
Thnaks in Advance!
Form1 consists of <Startup Form>
Label1
Button1
For2 consist of
textbox1
Button1
|
|
|
|
|
The simplest way is to set the access modifier of the textbox to public or friend, then set
label1.text = textbox1.text
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler.
Support Bone
It's a weird Life
|
|
|
|
|
just a thought..dont u hav to use inheritance to do this sorta thing?...I'm actully looking to do same thing as well but with no luk so far..
rubdub
|
|
|
|
|
Here it is -
Some background info for you that was given to me in the C# area
[Google on "Mediator pattern" and "MVC" (or "Model-View-Controller"). If you learn how to use these patterns, you'll never get stuck like this again; your code won't need tricks like passing a form to another form. I recommend "Design Patterns" by the Gang of Four.]
I just went to Microsoft ans sought out "Model-View-Controller"
As for the code. A no brainer once you do it, Key words "once you do it"
Once you have placed this very generic code in the forms and "Shared" class, go to project properties and
set the startup object to "Global" - this is you shared class, you can use this class or whatgever class you use for application prep, tracings and logs.
Option Strict On
Option Explicit On
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Global.postF2()
End Sub
End Class
Option Strict On
Option Explicit On
Public Class Form2
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
Global.postF1(TextBox1.Text)
End Sub
End Class
Option Strict On
Option Explicit On
Public Class Global
Public Shared f1 As Form1
Public Shared f2 As Form2
Public Shared Sub main()
f1 = New Form1
Application.Run(f1)
End Sub
Public Shared Function postF2() As String
f2 = New Form2
f2.Show()
End Function
Public Shared Function postF1(ByVal post As String) As String
f1.Label1.Text = post
End Function
|
|
|
|
|
create a fillschema a dataset
I create a SYBASECOMMANDBUILDER (from DDTEK Sybase Driver)
I create a row from the dataset
I fill the row with data
I add the row back to the datatable
[rowstate is now UNCHANGED]
I make a change to the newly added row
[rowstate is still UNCHANGED]
Of course the following update command returns zero, since there are no rows that do not have a status of "UNCHANGED". Can someone explain to me what I did wrong? datarow adds and changes should change the rowstate to Added and Modified respectively. Thanks in advance
Have a blessed day in Messiah EYAWHOOSHUA!
|
|
|
|
|
I dont know how to do that. Directly in the Keypress event. Someone can help me ?
I am a newbie
|
|
|
|
|
Your definition of what you need is lacking. However, if I understand correctly, in a KeyPress event, you want to take the key that was pressed and convert it to uppercase. If this is your goal, try this in your sub
<br />
Dim key As Char = UCase(e.KeyChar)<br />
Hope this helps
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
TextBox1.CharacterCasing = CharacterCasing.Upper
That's what I neeeded
I am a newbie
|
|
|
|
|
i need a function, method, or api with which you can send a form to botton, not to top, so that the form will appear behind all other windows and above the desktop
thank you in advance
|
|
|
|
|
Hi,
From VB you can use ZOrder,
MyForm.ZOrder 0 will send the form to the top of the z order
MyForm.ZOrder 1 will send it to the bottom of the z order
If you are looking for more control, check SetWindowPos API function,
BOOL SetWindowPos(
HWND hWnd,
HWND hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
UINT uFlags
);
where hWndInsertAfter is a handle to the window to precede the positioned window in the Z order or one of the following values.
HWND_BOTTOM
HWND_NOTOPMOST
HWND_TOP
HWND_TOPMOST
Check the MSDN for a detailed explanation.
Fabian
|
|
|
|
|
Hello,
I am new to VB.NET and i need to accomplish this task. I have a form that contains a radiobuttonlist.
<tr>
<td class="NavyBold">Choose a Category:</td>
<td><asp:checkboxlist id="chkcomm" Runat="server" RepeatDirection="Vertical" RepeatColumns="2" AutoPostBack="false">
<asp:ListItem Value="Europe"></asp:ListItem>
<asp:ListItem Value="Australia"></asp:ListItem>
<asp:ListItem Value="North America"></asp:ListItem>
<asp:ListItem Value="Central America"></asp:ListItem>
<asp:ListItem Value="South America"></asp:ListItem>
<asp:ListItem Value="Asia"></asp:ListItem>
</asp:checkboxlist></td>
</tr>
Base on the selection on this radiobutton list once the form is submitted I have to generate an email to the department that can answer questions base on the category they chose on my radiobuttonlist.
How can I code this so I can accomplish this task. All the help will be appreciated.
|
|
|
|
|
Hi there. Well, in your code you're using a CheckBoxList object... do you want a RadioButtonList instead? If you have a single selected value (as in a RadioButtonList ) you could use the following code to get it:
Dim sValue as String = chkcomm.SelectedValue Or for multiple selections (as in a CheckBoxList ) you could enumerate through the items to see which are selected with code like this:
Dim i as Integer
For i = 0 to chkcomm.Items.Count - 1
If chkcomm.Items(i).Selected Then
'... do something with the selected item...
End If
Next To send the email, investigate the System.Web.Mail namespace. Here's a simple example:
Imports System.Web.Mail
Sub SendAMessage(sSendTo as string, sSubject as string, sBody as string)
Dim mm as MailMessage = new MailMessage()
'--set message properties
mm.From = "me@mycompany.com"
mm.To = sSendTo
mm.Subject = sSubject
mm.Body = sBody
'--set the SMTP server that will handle the outgoing message
SmtpMail.SmtpServer = "mycompany.com"
'--send the message
SmtpMail.Send(mm)
End Sub In your case, you would probably use a Select Case...End Select block to set up the .To property, based on the selected values. If you want more examples just do a search on CodeProject.
|
|
|
|
|
Hi thanks for the help.
Am I in the right direction with this. Base on the value selected on my radio button list i need to send an email to the the corresponding person pertaining to the subject.
thank in advance for the feedback.
Dim sValue as String = chkcomm.SelectedValue
Dim i as IntegerFor i = 0 to chkcomm.Items.Count - 1
If chkcomm.Items(i).Selected = 'Europe'
Then
'Sub SendAMessage(sSendTo as string, sSubject as string, sBody as string)
Sub Message As MailMessage = New MailMessage
Message.From = "postmaster@test.net"
Message.To = "me@test.net"
Message.Subject = "Europe"
Message.Body = "There is a new Europe Form that was submitted.Please click on the following link http://test/testfolder/continets/Main.aspx"
Message.Cc = "you@test.net"
Message.Bcc = "us@test.net"
Try
SmtpMail.SmtpServer = "TESTIMC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
'End Sub
Else
chkcomm.Items(i).Selected = 'Australia'
Then
Sub Message As MailMessage = New MailMessage
Message.From = "postmaster@test.net"
Message.To = "me@test.net"
Message.Subject = "Australia"
Message.Body = "There is a new Autralia Form that was submitted.Please click on the following link http://test/testfolder/continets/Main.aspx"
Message.Cc = "you@test.net"
Message.Bcc = "us@test.net"
Try
SmtpMail.SmtpServer = "TESTIMC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Else
chkcomm.Items(i).Selected = Noth America'
Then
Sub Message As MailMessage = New MailMessage
Message.From = "postmaster@test.net"
Message.To = "me@test.net"
Message.Subject = "North America"
Message.Body = "There is a new Norht America Form that was submitted.Please click on the following link http://test/testfolder/continets/Main.aspx"
Message.Cc = "you@test.net"
Message.Bcc = "us@test.net"
Try
SmtpMail.SmtpServer = "TESTIMC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Else
chkcomm.Items(i).Selected = Central America'
Then
Sub Message As MailMessage = New MailMessage
Message.From = "postmaster@test.net"
Message.To = "me@test.net"
Message.Subject = "Central America"
Message.Body = "There is a new Central America Form that was submitted.Please click on the following link http://test/testfolder/continets/Main.aspx"
Message.Cc = "you@test.net"
Message.Bcc = "us@test.net"
Try
SmtpMail.SmtpServer = "TESTIMC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Else
chkcomm.Items(i).Selected = South America'
Then
Sub Message As MailMessage = New MailMessage
Message.From = "postmaster@test.net"
Message.To = "me@test.net"
Message.Subject = "South America"
Message.Body = "There is a new South America Form that was submitted.Please click on the following link http://test/testfolder/continets/Main.aspx"
Message.Cc = "you@test.net"
Message.Bcc = "us@test.net"
Try
SmtpMail.SmtpServer = "TESTIMC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
Else
chkcomm.Items(i).Selected = Asia'
Then
Sub Message As MailMessage = New MailMessage
Message.From = "postmaster@test.net"
Message.To = "me@test.net"
Message.Subject = "Europe"
Message.Body = "There is a new Europe Form that was submitted.Please click on the following link http://test/testfolder/continets/Main.aspx"
Message.Cc = "you@test.net"
Message.Bcc = "us@test.net"
Try
SmtpMail.SmtpServer = "TESTIMC01.TEST.com"
SmtpMail.Send(Message)
Catch ehttp As System.Web.HttpException
'Catch error here
End Try
End If
Next
|
|
|
|
|
Hi there. I'm guessing you are new to VB.NET? maybe new to programming? Generally I'd say you're on the right track, but you would certainly make your life easier to create a sub or function with parameters for sending the message. It looks like (for the moment) that the only properties changing for the message are the subject and body, and those are constructed from boiler-plate strings with the location. So, you could create your sub for sending the message with the location as a parameter:
Public Sub SendAMessage(sLocation as string)
dim Message As MailMessage = New MailMessage
Message.From = "postmaster@test.net"
Message.To = "me@test.net"
Message.Cc = "you@test.net"
Message.Bcc = "us@test.net"
'--set subject and body depending on the location
Message.Subject = sLocation
Message.Body = string.Format( _
"There is a new {0} Form that was submitted. " & _
"Please click on the following link: " & _
"http://test/testfolder/continents/Main.aspx", _
sLocation)
Try
SmtpMail.SmtpServer = "TESTIMC01.TEST.com"
SmtpMail.Send(Message)
Catch ex As Exception
'do something with the error...
'... also, make sure to look at the
'... InnerException property; in the case
'... of mail exceptions, often InnerException
'... will give some better information of
'... what is going wrong
dim innerEx as Exception = ex.InnerException
if not (innerEx is nothing) then
'--inspect the innerEx message...
'-- perhaps write out to the log
end if
End Try
End Sub Then in your main sub you would inspect your RadioButtonList for its value and call the SendAMessage() sub with the proper location as a parameter. Again, assuming you have a RadioButtonList and not a CheckBoxList , then SelectedValue should work fine.
Public Sub InspectLocationAndSend()
'--get the value of the selected radio button
'-- this assumes the value is the desired location, like 'Europe'.
dim sLocation as string = myRadioButtonList.SelectedValue
'--Now call the sub that actually constructs and sends the message,
' based on the location
SendAMessage(sLocation)
End Sub What book(s) are you using to learn VB.NET and ASP.NET?
|
|
|
|
|
Thank you for the help...I know ill get there.
I wrote the long code because indeed when one of the items on my checkboxlist is selected the email has to go to a different person ie.
if europe is selected then send email to test@test.com if North America is selected then test2@test.com gets that email and so on.
I am fairly new (well realllllly new to .net) so I appreciate the help.
|
|
|
|
|
Okay - you'll want a Select Case block then. You could, for example, modify the SendAMessage sub to inspect the location and set the .To message property accordingly:
Public Sub SendAMessage(sLocation as string)
dim Message As MailMessage = New MailMessage
Message.From = "postmaster@test.net"
'--set the .To property depending on the location
Select Case sLocation.ToUpper()
Case "NORTH AMERICA": Message.To = "naRecipient@test.net"
Case "EUROPE" : Message.To = "europeRec@test.net"
'... other cases ...
Case Else : Message.To = "defaultRec@test.net"
End Select
'... other code as before ...
End Sub
|
|
|
|
|
I have a two form project. Form1 has one button on it with two lines of code:
Dim f_form2 As New Form2
f_form2.ShowDialog()
Form2 reads in a .JPG from SQL Server and displays the .JPG in a picture box on Form2. All this works great UNTIL I close Form2 and call it a second time. Form2 blows up with the following message:
An unhandled exception of type 'System.IO.IOException' occurred in mscorlib.dll
Additional information: The process cannot access the file "C:\pic.jpg" because it is being used by another process.
If I close down the whole app and restart it, it's fine until the second call to Form2, so I'm obviously not releasing something correctly but don't know what to try. Help!
Thanks in advance.
*** here's the code ****
<br />
Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
<br />
Dim fs As New FileStream("C:\pic.jpg", FileMode.Create, FileAccess.Write) 'blows up here second time form is called<br />
Dim bw As New BinaryWriter(fs)<br />
<br />
Dim Buffersize As Integer = 16384<br />
Dim Outbyte(Buffersize - 1) As Byte<br />
Dim retval As Long<br />
Dim startindex As Long = 0<br />
Dim actualsize As Integer<br />
<br />
Dim ConString As String<br />
ConString = ("Persist Security Info=False;Integrated Security=SSPI;Data Source=(local);Database=db")<br />
<br />
Dim strSQLCommand As String<br />
strSQLCommand = "select blob_segment from blob where picid = 574739053"<br />
<br />
Dim Connection As New SqlConnection(ConString)<br />
<br />
Dim Command As New SqlCommand(strSQLCommand, Connection)<br />
<br />
Connection.Open()<br />
Dim Reader As SqlDataReader = Command.ExecuteReader(CommandBehavior.SequentialAccess)<br />
<br />
actualsize = 0<br />
<br />
Do While Reader.Read<br />
startindex = 0<br />
<br />
retval = Reader.GetBytes(0, startindex, Outbyte, 0, Buffersize)<br />
<br />
Do While retval = Buffersize<br />
MsgBox(Str(Buffersize))<br />
bw.Write(Outbyte)<br />
bw.Flush()<br />
startindex += Buffersize<br />
retval = Reader.GetBytes(0, startindex, Outbyte, 0, Buffersize)<br />
Loop<br />
<br />
bw.Write(Outbyte, 0, CInt(retval))<br />
bw.Flush()<br />
fs.Flush()<br />
bw.Close()<br />
fs.Close()<br />
<br />
Loop<br />
<br />
Reader.Close()<br />
Connection.Close()<br />
<br />
PictureBox1.Image = Image.FromFile("c:\pic.jpg")<br />
<br />
End Sub
|
|
|
|