|
Dear Friends
i have no knowladge on networking so i really dont know how to get this work. it seams like group of classes and how can i intigrate it with my forms to try it ? pleas help me out i need it so badly . can any one show me how to get it working ?!
if you could build it in vb and share it with me as a zip file i would be thankful.
there are the offical examples
1. Client : Example
2. Server : Example
Thanks In Advance
|
|
|
|
|
You know those code samples come in both C# AND VB.NET, right?
All you do is click on the VB tab at the top of the code sample.
|
|
|
|
|
Dear Friend
after pasting the code in my form where should i read incoming signals and how to initiate the connection ???
all these thing i dont know how to do them.
|
|
|
|
|
Those examples are written into Console applications, not Windows Forms apps.
You better do it in Console applications first and learn how the code works before you try to adapt the code to work in Windows Forms.
|
|
|
|
|
I have form1 and there is two flags ("Yes" and "No").when i select "Yes" and click on save button.It will open another form2.Once save form2 it will save form1 automatically.But it is giving error "conversion from string to type integer is not valid".please note that when i select "NO" it is not giving any error.please see my below code.
1)code for form1 save
Public Sub frmElogsheet_SAVE()
btneditelog.Enabled = False
btndelelog.Enabled = False
Dim conn As New SqlConnection
Dim cmd As New SqlCommand
' Dim dr As SqDataReader
conn = GetConnect()
conn.Open()
cmd.Connection = conn
Try
Dim code1 As Integer
Dim code2, code4, code5, code6, code7, code13 As String
Dim code8, code9 As Integer
Dim code3, code10, code11, code12 As Date
code1 = txtallocateelog.Text.ToString
code2 = txtvehicleElog.Text.ToString
code3 = txtRequestdateElog.Text.ToString
code4 = txtDestElog.Text.ToString
code5 = txtdeptElog.Text.ToString
code6 = txttravellerElog.Text.ToString
code7 = txtdvr2.Text.ToString
code8 = txtkmreaddept.Text.ToString
code9 = txtkmarr.Text.ToString
code10 = dtpdepttime.Text.ToString
code11 = dtparr.Text.ToString
code12 = dtpovertime.Text.ToString
code13 = Combacci.Text
'g900 = code2 'it will pass value to accident form
cmd.CommandText = "insert into tbElogsheet(Allocate_id,Number_plate,Depart_date,Destination,Department,Traveller,NAME,km_read_dept,km_read_arr,Departure_time,Arrival_time,Over_time,Accident) VALUES (" & code1 & ",'" & code2 & "','" & code3 & "','" & code4 & "','" & code5 & "','" & code6 & "','" & code7 & "'," & code8 & "," & code9 & ",'" & code10 & "','" & code11 & "','" & code12 & "','" & code13 & "')"
cmd.ExecuteNonQuery()
MsgBox("ELOGSHEET Added Sucessfully")
'frmElogsheet_clear() 'clear elogsheet items after saving
'txtkmreaddept.Text = g101
Catch ex As Exception
MsgBox(ex.Message)
End Try
'conn.Close()
End Sub
2)
Private Sub btnsaveElogsheet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
g900 = txtvehicleElog.Text.ToString
G901 = txtRequestdateElog.Text.ToString
G902 = txtdvr2.Text.ToString
Dim t13 As String
t13 = Combacci.Text.ToString
If t13 = ("Yes") Then
Dim frmeAccident As New frmeAccident 'Dim f1 As New frmeAccident()
frmeAccident.Show()
'Dim f1 As New frmeAccident()
Else
frmElogsheet_SAVE()
frmElogsheet_clear() 'clear elogsheet items after saving
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
3)Save for form2
Private Sub btnsaveacc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsaveacc.Click
Dim conn As New SqlConnection
Dim cmd As New SqlCommand
' Dim dr As SqDataReader
conn = GetConnect()
conn.Open()
cmd.Connection = conn
Try
'frmElogsheet.frmElogsheet_SAVE() 'CALL procedure frmElogsheet_SAVE() from frmElogsheet
Dim t2, t3, t4, t5, t6, t7, t8, t9 As String
Dim t1 As Integer
t1 = txtaccident.Text
t2 = txtaccplate.Text
t3 = txtdriver.Text
t4 = dtpeaccdept.Text
t5 = Cmbpolice.Text
t6 = txtlocacc.Text
t7 = txtamnt.Text
t8 = txtdesc.Text
t9 = Combacctype.Text
cmd.CommandText = "insert into tbeAccident values(" & t1 & ",'" & t2 & "','" & t3 & "','" & t4 & "','" & t5 & "','" & t6 & "'," & t7 & ",'" & t8 & "','" & t9 & "')"
cmd.ExecuteNonQuery()
MsgBox("Data Added Sucessfully")
'CODE CHANGES START
'cmd.CommandText = "Select * from tbDept_proj"
'Dim Adpt As New SqlDataAdapter(cmd.CommandText, conn)
'Dim ds As New DataSet()
'Adpt.Fill(ds, "tbDept_proj")
'grdviewdept.DataSource = ds.Tables("tbDept_proj")
'CODE CHANGES END
'frmeAccident_clear()
'close form start
'Dim frmeAccident As New frmeAccident
'frmeAccident.Close()
'Close()
'close form end
frmElogsheet.frmElogsheet_SAVE() 'CALL procedure frmElogsheet_SAVE() from frmElogsheet
Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
please help on this article urgently.
|
|
|
|
|
And you think we are going to look through that unformatted code dump to try and figure out (or guess) where this error occurs?
|
|
|
|
|
Dim code1 As Integer
code1 = txtallocateelog.Text.ToString
You declare code1 as an Integer but then you attempt to assign a String . The same goes for a bunch of other variables there which you have declared as Integer or DateTime . Take a look at Int32.TryParse Method (String, Int32) (System)[^] and DateTime.TryParse Method (String, DateTime) (System)[^] to solve this issue (other primitive types have equivalent .TryParse(..) -methods).
Apart from that: Calling .ToString() on a property of type String is redundant:
code2 = txtvehicleElog.Text.ToString
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
modified 20-Apr-16 8:40am.
|
|
|
|
|
Don't concatenate strings to form your database queries - use Parameterised queries.
For example:
cmd.CommandText =
"insert into tbElogsheet(Allocate_id,Number_plate,Depart_date,Destination,Department,Traveller,NAME,km_read_dept,km_read_arr,Departure_time,Arrival_time,Over_time,Accident) VALUES (@code1,@code2,@code3,@code4,@code5,@code6,@code7,@code8,@code9,@code10,@code11,@code12,@code13)"
cmd.Parameters.AddWithValue("@code1", code1)
cmd.Parameters.AddWithValue("@code2", code2)
cmd.Parameters.AddWithValue("@code3", code3)
cmd.Parameters.AddWithValue("@code4", code4)
cmd.Parameters.AddWithValue("@code5", code5)
cmd.Parameters.AddWithValue("@code6", code6)
cmd.Parameters.AddWithValue("@code7", code7)
cmd.Parameters.AddWithValue("@code8", code8)
cmd.Parameters.AddWithValue("@code9", code9)
cmd.Parameters.AddWithValue("@code10", code10)
cmd.Parameters.AddWithValue("@code11", code11)
cmd.Parameters.AddWithValue("@code12", code12)
cmd.Parameters.AddWithValue("@code12", code13)
cmd.ExecuteNonQuery()
This might well cure your problem.
If it does not then use the Debugger to determine which line is causing the problem and let us know.
|
|
|
|
|
Hi chill,
i am getting same error after modified.
Public Sub frmElogsheet_SAVE()
btneditelog.Enabled = False
btndelelog.Enabled = False
Dim conn As New SqlConnection
Dim cmd As New SqlCommand
' Dim dr As SqDataReader
conn = GetConnect()
conn.Open()
cmd.Connection = conn
Try
Dim code1 As Integer
Dim code2, code4, code5, code6, code7, code13 As String
Dim code8, code9 As Integer
Dim code3, code10, code11, code12 As String 'date
code1 = txtallocateelog.Text
code2 = txtvehicleElog.Text
code3 = txtRequestdateElog.Text
code4 = txtDestElog.Text
code5 = txtdeptElog.Text
code6 = txttravellerElog.Text
code7 = txtdvr2.Text
code8 = txtkmreaddept.Text
code9 = txtkmarr.Text
code10 = dtpdepttime.Text
code11 = dtparr.Text
code12 = dtpovertime.Text
code13 = Combacci.Text
'g900 = code2 'it will pass value to accident form
'cmd.CommandText = "insert into tbElogsheet(Allocate_id,Number_plate,Depart_date,Destination,Department,Traveller,NAME,km_read_dept,km_read_arr,Departure_time,Arrival_time,Over_time,Accident) VALUES (" & code1 & ",'" & code2 & "','" & code3 & "','" & code4 & "','" & code5 & "','" & code6 & "','" & code7 & "'," & code8 & "," & code9 & ",'" & code10 & "','" & code11 & "','" & code12 & "','" & code13 & "')"
'cmd.ExecuteNonQuery()
cmd.CommandText ="insert into tbElogsheet(Allocate_id,Number_plate,Depart_date,Destination,Department,Traveller,NAME,km_read_dept,km_read_arr,Departure_time,Arrival_time,Over_time,Accident) VALUES (@code1,@code2,@code3,@code4,@code5,@code6,@code7,@code8,@code9,@code10,@code11,@code12,@code13)"
cmd.Parameters.AddWithValue("@code1", code1)
cmd.Parameters.AddWithValue("@code2", code2)
cmd.Parameters.AddWithValue("@code3", code3)
cmd.Parameters.AddWithValue("@code4", code4)
cmd.Parameters.AddWithValue("@code5", code5)
cmd.Parameters.AddWithValue("@code6", code6)
cmd.Parameters.AddWithValue("@code7", code7)
cmd.Parameters.AddWithValue("@code8", code8)
cmd.Parameters.AddWithValue("@code9", code9)
cmd.Parameters.AddWithValue("@code10", code10)
cmd.Parameters.AddWithValue("@code11", code11)
cmd.Parameters.AddWithValue("@code12", code12)
cmd.Parameters.AddWithValue("@code13", code13)
cmd.ExecuteNonQuery()
MsgBox("ELOGSHEET Added Sucessfully")
'frmElogsheet_clear() 'clear elogsheet items after saving
'txtkmreaddept.Text = g101
Catch ex As Exception
MsgBox(ex.Message)
End Try
'conn.Close()
End Sub
|
|
|
|
|
|
See the replies from Sacha and Richard. Fix the line
code1 = txtallocateelog.Text and also the lines for Code and Code.
Alternatively use the text box values for the cmd.Parameter values and you should not have to do any parsing or converting
|
|
|
|
|
Hi Team,
Now issue resoved.Thanks for your valauable support.
Regards
kishore
|
|
|
|
|
I'm not one to hate on VB6, but today's gonna be an exception. Also I want this message to be on the internet so the next poor swine who gets this message might be lucky enough to see this post.
I recently added some functionality to an OCX in our legacy VB6 system. The OCX compiled without errors, but any program that used it could no longer load it. When I tried to reference it in a new project, I got the error "File not found: 'C:\Users\???\AppData\Local\Temp\VBB685.tmp'".
About a week of tearing my hair out followed. I'd just upgraded to windows 10, I'm still not sure if that's relevant.
The thing is, I added a property. Removing it fixed the bug. Adding ANY property broke it again. Eventually I broke compatibility, made two functions which were Public but could/should have been Private .. um, Private, and added my property again. Now it's all good.
I can only assume there's some sort of really small limit on the number of exposed properties of a VB6 OCX. If this is/was common knowledge, well then what the hell google :p
|
|
|
|
|
There is no limit on the number of properties. I would guess, however, that it had something to do with your compatibility setting in the project. I'm not going to try and guess what because it's been about 15 years since I last touched VB6. Yay me!
|
|
|
|
|
By adding a property you broke the "contract" between the OCX and it's clients. Forcing the break compatibility is the only way (AFAIK) to get around it without supplying another interface. You will probably also have to rebuild any project that uses the OCX
|
|
|
|
|
Hi,
I need the minimum margin in vba excel or word.
I know how to set it in vba and in dot net. But I can't find the minimum in vba.
I guess I will need some API but if I find something usefull I must know the hdc and that I also can't find that. in vb6 there was printer.hdc but not in vba.
Who can help me?
Jan
|
|
|
|
|
Minimum margins are dependent on the print device that you are sending the output to. I would guess you need to look at printer properties.
|
|
|
|
|
Hi,
I know but I have looked and can't find it.
Our old printers have lesser margings that the new. now we have AGAIN different margings so I want to use the printer minimum possible margin and >.5cm so when I can read them a simple if then, structure will help me. but now I can't read it.
remember it's in VBA
Jan
|
|
|
|
|
Sorry, I am not a VBA expert, and this forum is mostly for VB/VB.NET questions.
|
|
|
|
|
I know but this the best forum I know
|
|
|
|
|
There are forums dedicated to VBA, you should try one. Just Google something like "VBA printer settings", and see what it gets you.
|
|
|
|
|
hello ...
can you help me please
how can change font size in richtextbox ,if selection some text in rtb have a more than one font name
if rtb.selection isnot nothing then
rtb.selectionfont=new font(rtb.selection.fontfamily,cint(combobox1.selecttext))
else
this statment can not programming
endif
|
|
|
|
|
|
Member 12436170 wrote: if selection some text in rtb have a more than one font name You have the selection-start, and its length.
Select the first character, get the name of its font, and increase its size. Repeat for the next character.
Bonuspoints if you keep increasing the selection if the next character has the same font.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi.
I got this error and can't seem to solve it. I've changed the code but it gives a error message that I have coded into the program. I've read most of the articles here about it but just can't figure it out. This is the line of code; msgBox(sendWeightRequest). I have changed it to this;
Private Sub btnGet_Click(sender As System.Object, e As System.EventArgs) Handles btnGet.Click
If sendWeightRequest() = "ERROR" Then
WriteLine("Cannot read weight...")
Else
MessageBox.Show(sendWeightRequest)
End If
End Sub
When I run the program it doesn't give the Modules error message but another ones. Can someone help please?
|
|
|
|
|