|
Hello everyone,I'm new to VB.NET. I am having problem with migrating the following code from VB to VB.NET.I'm a new beginner on this VB.NET. This code doesn't run at all in VB.NET. Anyone can please give me a solution to change it to VB.NET?
VB Code:
Private Sub Spam()
Set con1 = New ADODB.Connection
con1.Open conStr1
Set rs1 = New ADODB.Recordset
Set rs1.ActiveConnection = con1
Set rs2 = New ADODB.Recordset
Set rs2.ActiveConnection = con1
sql1 = "SELECT TOP 20 * FROM TT_Member WHERE Reminder = '0' AND Status = '1'"
rs1.Open (sql1)
If rs1.EOF And rs1.BOF Then
Label1.Caption = "Finished - " & Now
Else
Do Until rs1.EOF
Label1.Caption = "Spamming - " & Now
OriginatingAddress = rs1.Fields("Mobile_No").Value
If Mid(OriginatingAddress, 1, 3) = "601" Then
Telco = 2
ElseIf Mid(OriginatingAddress, 1, 3) = "013" Then
Telco = 3
End If
Reminder_Msg = "You are charged $2."
MT_Msg = Reminder_Msg
MT_Msg = Replace(MT_Msg, "datedate", Renewal_Date3)
rs1.MoveNext
Loop
End If
End Sub
Hope someone can give me a solution here. Thank you so much~!
|
|
|
|
|
vb and vb.net are like a mango and a mango tree. pls familarize yourself with the concepts of ado.net.
this is a sample code. this is for insertion. try this out.
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlDbType
Public Function inserttotables()
Dim sqlcon1 As New SqlConnection(constr)
Dim sqlcon As New SqlConnection(constr)
Dim strq1, strq2 As String
sqlcon1.Open()
sqlcon.Open()
strq1 = "insert into BillCommonDet(BillNo,BillDate,Customer,Doctor,Pharmacist,GrossTotal,Discount,NetTotal,AmtReceived,Balance)values(@BillNo,@BillDate,@Customer,@Doctor,@Pharmacist,@GrossTotal,@Discount,@NetTotal,@AmtReceived,@Balance)"
strq2 = "insert into BillProductDet(Billno,Billdate,PID,PName,BatchNo,MfgDate,ExpDate,UnitPrice,ReqQty,Tax,Amount) select billno,billdate,pid,pname,batchno,mfgdate,expdate,unitprice,reqqty,tax,amt from TempCustBill"
Dim cmdstring As New SqlCommand(strq1, sqlcon1)
Dim cmdstr As New SqlCommand(strq2, sqlcon)
cmdstring.Parameters.Add("@BillNo", TextBillNO.Text.Trim)
cmdstring.Parameters.Add("@BillDate", DateTimeDate.Text.Trim)
cmdstring.Parameters.Add("@Customer", TextCustomer.Text.Trim)
cmdstring.Parameters.Add("@Doctor", doctor)
cmdstring.Parameters.Add("@Pharmacist", pharmacist)
cmdstring.Parameters.Add("@GrossTotal", Val(TextGrandTotal.Text.Trim))
cmdstring.Parameters.Add("@Discount", Val(TextDiscount.Text.Trim))
cmdstring.Parameters.Add("@NetTotal", Val(TextNetTotal.Text.Trim))
cmdstring.Parameters.Add("@AmtReceived", Val(TextAmtRec.Text.Trim))
cmdstring.Parameters.Add("@Balance", Val(TextBalance.Text.Trim))
Try
cmdstring.ExecuteNonQuery()
cmdstr.ExecuteNonQuery()
cmdstr.Dispose()
cmdstring.Dispose()
sqlcon1.Close()
sqlcon1.Dispose()
sqlcon.Close()
sqlcon.Dispose()
Catch x As SqlException
MessageBox.Show(x.Message)
End Try
End Function
|
|
|
|
|
Hello there,I am sorry because I'm really a beginner. I think your code doesn't really help me because I need to select the data row by row inside the dataset. And used movenext function with loop together.I found that there is no more BOF and EOF function. Can you give me a better solution code? Any other example which is more similar to what I need can show me please?
Thank you ~!
Regards
Drexler
|
|
|
|
|
|
I couldnt find the VB6 Message board hope u wudnt mind asking question here.
I want to create vb6 forms dynamically . i have form names in database and i want to create form of that specific name on fly
R A M
|
|
|
|
|
I don't think it's possible in VB6 because it doesn't support reflection.
In VB.NET, this is not a problem.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I think an array of type Forms could be helpful (if I have got you correctly):
dim forms() as Form
....
redim preserve form ( ubound(forms) + 1 )
set forms ( ubound ( forms) ) = new form
...
hope it helps
|
|
|
|
|
I have got the solution ...
Forms Collection is used for Loaded forms in memory
so
Forms.Add(rs("FormName"))
for each frm in forms
if frm.name="Form2" then
frm.show
end if
R A M
|
|
|
|
|
Dear guys
How can I change background color of toolbar and MDI form?
Thanks in advance.
Mahbub8957
|
|
|
|
|
To change Background color of MdI form
Do not set isMDIcontainer property of the MDI form to true. Add the following code.
Private Sub test_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim mdiClient1 As MdiClient = New System.Windows.Forms.MdiClient
mdiClient1.Dock = System.Windows.Forms.DockStyle.Fill
mdiClient1.Name = "mdiClient1"
mdiClient1.BackColor = Color.DarkCyan
Me.Controls.AddRange(New System.Windows.Forms.Control() {mdiClient1})
Me.IsMdiContainer = True
Dim frm As Form1 = New Form1
frm.MdiParent = Me
frm.Show()
End Sub
this should work for mdi form.
How to change the background color of a toolbar:
1.Place a panel on your form
2.Set the panel's docked property to Top (the default for a toolbar)
3.Set the panels backcolor to the color that you want the toolbar to be
4.Place a toolbar on the panel mentioned above
The Toolbar & its buttons inherit their backcolor from their parent control. Seems simple enough.
You could always 'subclass the toolbar and do the drawing yourself' but for a newbie to VB simple is best.
|
|
|
|
|
hi,
plz help me...how to send email using VB6.0
is possible send me the link or code for that
bye
Paritosh
|
|
|
|
|
Dear
MAPI control may fulfill your requirements.
Thanks
Mahbub8957
|
|
|
|
|
Thanks but
do u have any sample program or link
bye
Paritosh
|
|
|
|
|
sample program is avaiable in MSDN. Just make a search indicating MAPI control.
Mahbub8957
|
|
|
|
|
my machine doesnot have MSDN.
If you have any sample or link then jusd otherwise no probs.
Paritosh
|
|
|
|
|
paritosha wrote: my machine doesnot have MSDN.
But the internet does!
http://msdn.microsoft.com
|
|
|
|
|
I hope i will be usefull
it is a my old program
http://www.fulminegiallo.it/AnoniMail.zip
|
|
|
|
|
http://lab.msdn.microsoft.com/searchbeta/Default.aspx?query=MAPI+Control
Mahbub8957
|
|
|
|
|
|
I am very new to VB.Net programming.
I am uploading data from one branch office to another
through modem connections of telephone line.
As i am using the MSComm Control And Also NetCommOcx
ActiveX Controls,but as when it is comming to
any one of the properties of the either control,
it is throwing an exception as
An unhandled exception of type 'InvalidActiveXStateException' occurred in
axinterop.NetCommOcx.dll
I hav searched at internet but of no use.
since i hav imported System.Runtime.InteropServices
there is no use.
kindly give a sol to the problem.
I am sending the Module where the properties of the control is used
Imports System.Object
Imports NETCommOCX.NETCommClass
Imports IClean.Mdl_MSCommVariables
Imports System.Runtime.InteropServices
Imports System.Windows.Forms.AxHost
Public Class MdlCl_MSComm
Public WithEvents MsComm1 As New AxNETCommOCX.AxNETComm
Public Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Dim Modem_Present As Boolean
Public Sub init()
Try
MsComm1.RThreshold = 1
MsComm1.SThreshold = 1
MsComm1.InputLen = 0
MsComm1.CommPort = 1
MsComm1.PortOpen = True
Call Clear_Buffer()
MsComm1.set_Output("ATV1Q0" & Chr(13)) 'Send Attention To the Modem.
'MsComm1.Output = "ATDT" & "055782588" & Chr(13) 'AT tells the modem that a command is coming up.DT tells it to dial the upcoming number using Tone dial.
MsComm1.Handshaking = NETCommOCX.HandshakeConstants.comRTS 'Able to connect and send data but not receive data.
MsComm1.set_Settings("9600,N,8,1")
'AddHandler MsComm1.OnComm, AddressOf MsComm1_OnComm
Catch ex As System.Runtime.InteropServices.COMException
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
End Try
End Sub
Public Sub Dial()
Try
MsComm1.set_Output("ATDT" & "055782588" & Chr(13)) 'AT tells the modem that a command is coming up.DT tells it to dial the upcoming number using Tone dial.
Sleep(600)
' Ask the user to wait until the phone rings.
'MessageBox.Show("When you hear a busy signal, click OK." & vbCrLf & "When you hear a ringing signal, pick up the receiver and click OK.", vbInformation Or vbOKOnly, "Please Wait")
MessageBox.Show("When you hear a busy signal, click OK.", "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
Catch ex As System.Runtime.InteropServices.COMException
MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
End Try
End Sub
Public Sub Clear_Buffer()
MsComm1.OutBufferCount = 0 'Returns the number of characters waiting in the transmit buffer.
MsComm1.InBufferCount = 0 'Returns the number of characters waiting in the receive buffer.
End Sub
Public Sub Phone_Number(ByVal num As Integer)
Try
MsComm1.set_Output(num)
Sleep(800)
Catch ex As Exception
MessageBox.Show(ex.ToString, "Modem Details", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
End Try
End Sub
Public Sub Data_Transmit_Terminate()
MsComm1.RTSEnable = False 'Disable The "Request To Send" Line.
End Sub
Public Sub Data_Recieve_Terminate()
MsComm1.DTREnable = False 'Disable The "Data Terminal Ready" Line.
End Sub
Public Sub Terminate_Connection() 'Connection is Closed.
MsComm1.PortOpen = False
MsComm1.RTSEnable = False
MsComm1.DTREnable = False
End Sub
Public Sub Modem_Connect()
End Sub
Public Sub Send_Data(ByVal dat As String)
MsComm1.set_Output(dat)
Sleep(500)
End Sub
'Returns the most recent communication event or error.
Private Sub MsComm1_OnComm(ByVal sender As Object, ByVal e As System.EventArgs) Handles MsComm1.OnComm
'Modem_Input = MsComm1.Input
Select Case MsComm1.CommEvent
Case NETCommOCX.NETCommConstants.NETComm_EV_SEND
status = "Sending . . . "
Exit Select
Case NETCommOCX.NETCommConstants.NETComm_ER_BREAK
Case NETCommOCX.NETCommConstants.NETComm_EV_RING
status = "Ringing . . . "
Exit Select
Case NETCommOCX.NETCommConstants.NETComm_ER_RXPARITY
Case NETCommOCX.NETCommConstants.NETComm_ER_RXOVER
Case NETCommOCX.NETCommConstants.NETComm_EV_EOF
End Select
'If MsComm1.CommEvent = 6 Then
' status = "Ring . . . "
'ElseIf MsComm1.CommEvent = 1 Then
' status = "Transfer Data . . . "
'End If
'If MsComm1.CommEvent = 1001 Then
' MessageBox.Show("Break Signal Is Recieved.", "Modem Details", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
'ElseIf MsComm1.CommEvent = 1004 Then
' MessageBox.Show("Framing Error.", "Modem Details", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
'ElseIf MsComm1.CommEvent = 1009 Then
' MessageBox.Show("Parity Error.", "Modem Details", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
'ElseIf MsComm1.CommEvent = 1010 Then
' MessageBox.Show("Transmit Buffer Full.", "Modem Details", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
'ElseIf MsComm1.CommEvent = 1011 Then
' MessageBox.Show("Unexpected Error.", "Modem Details", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
'End If
End Sub
End Class
neelima
|
|
|
|
|
Hello everyone,I'm still migrating the VB to VB.NET Engine here.I am a beginner to VB.NET. I found this error message while I'm coding,can anyone give me a help please?
Overload resolution failed because no accessible 'New' can be called without a narrowing conversion: 'Public Sub New(selectCommandText As String, selectConnection As System.Data.SqlClient.SqlConnection)': Argument matching parameter 'selectConnection' narrows from 'System.Object' to 'System.Data.SqlClient.SqlConnection'. 'Public Sub New(selectCommandText As String, selectConnectionString As String)': Argument matching parameter 'selectConnectionString' narrows from 'System.Object' to 'String'.
And the following is my code>>
Private Sub Spam_Now()
Dim MemberDV As DataView
Dim i As Integer
Dim sql1, sql2, sql3 As String
'sql1 = "SELECT TOP 20 * FROM TT_Member WHERE Reminder = '0' AND Status = '1'"
ObAdapter1 = New SqlDataAdapter("SELECT TOP 20 * FROM TT_Mber WHERE Reminder = '0' AND Status = '1'", Obconn1) '<
|
|
|
|
|
drexler_kk wrote: Argument matching parameter 'selectConnectionString' narrows from 'System.Object' to 'String'.
You are passing a String parameter for an SQLConnection object. The argument you are passing must be an SQLConnection object and not String object.
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#aabbcc;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Thanks for your solution. Do you mean that I should change that line to the following?
ObAdapter1 = New SqlDataAdapter(Obconn1, "SELECT TOP 20 * FROM TT_Member WHERE Reminder = '0' AND Status = '1'")
ds1 = New DataSet
ObAdapter1.Fill(ds1, "MemberList")
I have try but it works,so I just want to reconfirm that is what you ask me to modified?
Thank you so much for the solution and effort.
Regards
Drexler
|
|
|
|
|
|
Yeah,thank you so much. I really learn from your advice. Good solution.
Regards
Drexler
|
|
|
|
|