I need to fetch the values to textbox from one form to another .
This is my code
Private Sub display()
connection = New SqlConnection(con)
Dim Sql As String = "SELECT ID,Name from tblTickets where stu='A' order by Name"
da1 = New SqlDataAdapter(Sql, connection)
'conn.Open()
ds1 = New DataSet()
Dim commandBuilder1 As SqlCommandBuilder = New SqlCommandBuilder(da1)
da1.Fill(ds1, "Pub")
dsource1.DataSource = ds1.Tables("Pub")
connection.Close()
DataGridView3.DataSource = dsource1
DataGridView3.Refresh()
DataGridView3.Columns(0).Width = 100
DataGridView3.Columns(1).Width = 200
End Sub
Private Sub DataGridView3_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView3.CellContentClick
i = DataGridView3.CurrentRow.Index
Dim dgv As DataGridView = CType(sender, DataGridView)
Dim thisCell As DataGridViewCell = dgv.SelectedCells(0)
Dim selCell As Integer = thisCell.ColumnIndex
Dim sch As New Schedules
sch.txtID.Text = DataGridView3.Item(0, i).Value.ToString()
'Form1.txtflight.Text = DataGridView3.Item(1, i).Value.ToString
Me.Dispose()
End Sub
8 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Sathya NarayanPosted Jun 25, 2014, 5:04 AM
Hi,
I am Loading the values from listview to textbox and combobox,it has just loading for textbox and which has not been loading to combobox.This is what the code, i am using to implement.
Filling To List View
Fetching The Values To ListView to Textbox and Combobox
With Regards,
Sathya
VulpesPosted Mar 20, 2014, 9:55 AM
To get rid of it, just initialize these variables to zero say:
double fm = 0.0;
double sm = 0.0;
The reason for the second set of errors is that you haven't parsed the text values to the double parameters the method is expecting. Also the method is not returning a value.
So change the method signature to:
public double TotalMarks(double m1, double m2, double m3)
and add this line at the foot of the method:
return avg;
Sathya NarayanPosted Mar 20, 2014, 2:07 AM
I am trying to calculate the internal marks of an student.Taking 4 textboxes in that 3 textboxes for internals marks and 4th textbox for calculating the average marks of the student
i am getting an error message while calculating the values using this formula.
This is my code
public void TotalMarks(double m1, double m2, double m3)
{
double fm;
double sm;
double avg;
if((m1>=m2 )&(m1>=m3))
{
fm = m1;
if (m2 >= m3)
{
sm = m2;
}
else
{
sm = m3;
}
}
if ((m2 >= m3) & (m2 >= m1))
{
fm = m2;
if (m1 >= m3)
{
sm = m3;
}
else
{
sm = m3;
}
}
if ((m3 >= m2) & (m3 >= m1))
{
fm = m1;
if (m1 >= m2)
{
sm = m1;
}
else
{
sm = m2;
}
}
avg = (fm+sm) / 2; // error unassinged local variable fm and sm
}
private void txtfi_TextChanged(object sender, EventArgs e)
{
txtam.Text = TotalMarks((txtfi.Text), (txtsi.Text), (txtti.Text)); //error cannot convert string to double
}
private void txtsi_TextChanged(object sender, EventArgs e)
{
txtam.Text = TotalMarks((txtfi.Text), (txtsi.Text), (txtti.Text)); //error cannot convert string to double
}
private void txtti_TextChanged(object sender, EventArgs e)
{
txtam.Text = TotalMarks((txtfi.Text), (txtsi.Text), (txtti.Text)); //error cannot convert string to double
}
}
can you please help?
VulpesPosted Mar 19, 2014, 5:58 AM
Sathya NarayanPosted Mar 19, 2014, 5:49 AM
Thanks for your reply.It has got changed in project-->properties instead of Windows Form Application,i took the value Windows Service.For that issue it wasn't take the showdailog function.Now it is working fine.
regards
satya
VulpesPosted Mar 18, 2014, 6:36 AM
Anyway, there are other ways to get a reference to an existing instance of a form.
Try replacing this line:
This code assumes that txtId is placed directly on the Schedules form and not in some container such as a Panel or GroupBox.
Sathya NarayanPosted Mar 18, 2014, 3:36 AM
VulpesPosted Mar 17, 2014, 9:45 AM
i = DataGridView3.CurrentRow.Index
Dim dgv As DataGridView = CType(sender, DataGridView)
Dim thisCell As DataGridViewCell = dgv.SelectedCells(0)
Dim selCell As Integer = thisCell.ColumnIndex
Schedules.txtID.Text = DataGridView3.Item(0, i).Value.ToString()
Me.Dispose()
The important thing here is not to create a new instance of Schedules.
The above code should access the existing instance, albeit using hidden code generated by the VB.NET compiler.