|
You open the file, read the first line compare it to the condition, if it passses then you display the second line.
What part is giving you problems?
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Dear CWIZO,
Here is my code below, with this code, I can read how many lines that met the condition, but I can not read the second line. Can you help me out. I would appreciate your potential helps very much,
<br />
Private Sub BtnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSend.Click<br />
Dim Start As String = "Start"<br />
Dim intTotalCount As Integer<br />
intTotalCount = CountStringInFile(strFile, Start) <--HERE, I CAN READ HOW MANY LINE MET THE CONDITION<br />
end Sub<br />
<br />
Private Function CountStringInFile(ByVal FilePath As String, ByVal StringToLookFor As String) As Integer<br />
Dim strContent As String = ""<br />
<br />
'Get a StreamReaderclass that can be used to read the file <br />
Dim objStreamReader As StreamReader<br />
<br />
Dim intCount As Integer<br />
Dim intCountahead As Integer = 1<br />
<br />
objStreamReader = File.OpenText(FilePath)<br />
<br />
While objStreamReader.Peek <> -1<br />
<br />
strContent = objStreamReader.ReadLine<br />
intCount += CountLineByLine(strContent, StringToLookFor)<br />
End While<br />
<br />
'Close the stream <br />
objStreamReader.Close()<br />
<br />
objStreamReader = Nothing<br />
<br />
Return intCount<br />
<br />
End Function<br />
<br />
Private Function CountLineByLine(ByVal vstr As String, ByVal strToSearch As String) As Integer<br />
Dim intIndex As Integer<br />
<br />
Dim intCount As Integer = 0<br />
<br />
intIndex = InStr(vstr, strToSearch)<br />
<br />
While intIndex > 0<br />
<br />
intCount += 1<br />
<br />
intIndex = InStr(intIndex + 1, vstr, strToSearch)<br />
<br />
End While<br />
<br />
Return intCount<br />
<br />
End Function<br />
|
|
|
|
|
Please how do I access and manipulate the value input into a textbox I created at runtime. the code is shown below. When i run it an error "object reference not set to an instance of an object" is shown
Dim x As Integer, b As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim y As New System.Drawing.Point(8, 48)
If (IsNumeric(txtdata_num.Text)) Then
x = CInt(txtdata_num.Text)
Try
For b = 0 To x - 1
Dim st(b) As System.Windows.Forms.TextBox
st(b) = New System.Windows.Forms.TextBox()
st(b).Location = y
st(b).Name = "textbox" & b
st(b).Size = New System.Drawing.Size(40, 40)
st(b).Visible = True
Me.Controls.Add(st(b))
y = New System.Drawing.Point(st(b).Location.X + st(b).Size.Width, st(b).Location.Y)
If (b + 1) Mod 10 = 0 Then
y = New System.Drawing.Point(st(0).Location.X, st(b).Location.Y + st(b).Size.Width + 5)
Else
End If
Next
Catch ea As Exception
MsgBox(ea.Message)
End Try
End If
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
For b = 0 To x - 1
st(b) = New System.Windows.Forms.TextBox()
'Dim st(b) As System.Windows.Forms.TextBox
If st(b).Text <> "" And IsNumeric(st(b).Text) Then
Dim ad As Integer
ad = Val(st(b).Text) + Val(st(b + 1).Text)
MsgBox(ad)
End If
Next
End Sub
Fikunmi Feyijin
Hicad Systems
Nigeria
|
|
|
|
|
You have to loop through the controls on the form (or container control) to find the one you want.
For example:
Dim ad As Integer = 0
Dim objControl As Object
For Each objControl In Me.Controls
If TypeOf objControl Is TextBox Then
If objcontrol.Text <> "" And IsNumeric(objcontrol.Text) Then
ad += Val(objcontrol.Text)
MsgBox(ad)
End If
End If
Next
|
|
|
|
|
Thanks the code worked. But I want to get the properties of any of the textboxes at random and access them with the name I created for them at runtime.
Dim ad As Integer = 0
Dim objControl As Object
For Each objControl In Me.Controls
If TypeOf objControl Is TextBox Then
If objcontrol.Text <> "" And IsNumeric(objcontrol.Text) Then
ad += Val(objcontrol.Text)
MsgBox(ad)
End If
End If
Next
Fikunmi Feyijin
Hicad Systems
Nigeria
|
|
|
|
|
I would use the Tag property to set some unique key that you can use to reference the text box while looping through to know when you have got the right one.
|
|
|
|
|
i'm using a SQL Server 2000.
now want i want is to make one of the machine on my local network
Machine one: i've installed the SQL Server 2000 with these settings
1) Use Local System
2) MixMode (Use Windows Authentication and SQL Server Authentication)
USER ID = sa
Password = sa
From Machine tow which has the program: the connection string is:
<<< Me.SQLConnection_Search.ConnectionString = "packet size=4096;integrated security=SSPI; Persist Security Info=true; data source= "the name of the instance on Machine ONE"; user id=sa; password=sa; initial catalog=DBNEW; Server="Machine One Name">>>>>>>
when i connect --> "connect faild to MachineOne\Guest"
when i changed the SERVER to SERVER = "Machine One Name\User Account of the windows"
this message appear : "SQL Server does not exist or access is denied"
So what can i do.??????
Faris Madi
Nothing Comes Easy (N.C.E.)
|
|
|
|
|
I'm not sure what your doing but the way I connect to local database is:
Dim cn As SqlConnection = New SqlConnection("workstation id=yourcomputername;packet size=4096;integrated security=SSPI;data source=yourcomputername;persist security info=False;initial catalog=yourdatabasename")
|
|
|
|
|
Hi
I need to show the context menu (right click menu) of a file/folder. I have a dll (written in C) which takes the address and a location and displays the context menu of the specified file/folder in the specified location in the screen. The dll is sure using API calls. I would like to have the code in vb6. I'd be glad if someone could let me know what API's and how...
Thanks in advance
|
|
|
|
|
I am working on a project and need some help with how to code something.
What I am trying to accomplish is on my Form I have a Group Box, within that group box I have 6 Check Boxes. What I want to accomplish is that the user can select up to 2 of these checkboxes and when they select the 2nd one it makes the other 4 that are not checked disabled, however if they uncheck one of the 2 remaining boxes it should uncheck and enable the other check boxes.
Any help on how to accomplish this is greatly appreciated.
|
|
|
|
|
Write a event handler for the checkbox you wan't to handle and then set the Checked property to true/false in there.
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
I'm having trouble setting up a stored procudure call. Using VB.NET and SQL Server 2000.
sp_GetInfo is procedure with 4 variables 1 input user and 3 outputs lname,fname, email. Below is the code generated by .NET when I added the stored Procedure. Can someone let me know is this correct and assist with being able to retrieve the info. I added the stored procedure directly because it would not allow me to user and sqldataadapter and then created a dataset.
Me.SqlSelectCommand2.CommandText = "[sp_GetInfo]"
Me.SqlSelectCommand2.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlSelectCommand2.Connection = Me.SqlConnection2
Me.SqlSelectCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
Me.SqlSelectCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@user_name", System.Data.SqlDbType.VarChar, 50))
Me.SqlSelectCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@last_name", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Output, False, CType(0, Byte), System.Data.DataRowVersion.Current, Nothing))
Me.SqlSelectCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@first_name", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Output, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
Me.SqlSelectCommand2.Parameters.Add(New System.Data.SqlClient.SqlParameter("@email", System.Data.SqlDbType.VarChar, 100, System.Data.ParameterDirection.Output, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
CType(Me.MyData1, System.ComponentModel.ISupportInitialize).EndInit()
Mike
|
|
|
|
|
I am using Visual Studio 2005. I created and strong-named a control and installed that control in the GAC successfully. I now want to add that control to the toolbox but it is not showing up in the .Net components portion of the 'Choose Toolbox Items' dialog. There is no question that it is installed in the GAC. Does anyone know why a successfully installed GAC control would not show up in the 'Choose Toolbox Items' dialog?
Thank you.
|
|
|
|
|
Because you have to add it to the Toolbox yourself. The ToolbBox doesn't "auto-populate" itself out of the GAC. Right-click in the ToolBox, pick Add/Remove Items...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I think you misunderstood my question. I am trying to add the control to the toolbox, and I did right-click in the toolbox and picked 'Choose Toolbox Items' (VS Studio 2005's verbiage). So, I have basically done everything you've suggested, my problem is that when the 'Choose Toolbox Items' dialog opens, the assembly I have successfully installed in the GAC is not listed under .Net Framework Components. I'm trying to understand why it would not be listed, and what else besides installing the Assembly in the GAC I need to do to ensure the assembly shows up in that dialog so I can add the control to the toolbox.
|
|
|
|
|
Dear, I have a .msi file.
i want to run it from a vb6 exe, I mean I should call it from the code.
can anyone help me with this, what is the syntax for calling a .msi file.
thanks
|
|
|
|
|
You can launch it like any other process you launch using the Shell function.
Dim progID As Integer
progID = Shell("""fully qualified path to msi""", vbNormalFocus)
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks in advance for any help guys. So the point of the following code is to install a CAB file onto a WM5 handheld. It has worked before, but is in no way consistent. It runs wceload.exe, the installer, fine, but upon returning to the point where it would update the forms again, it freezes. I think this has something to do with my threads, either the ones being created by CreateProcess or by WaitForSingleObject. It seems to me that only the thread that owns the forms and controls can change them, and I'm guessing that my current thread must not be the correct one. Both CreateProcess and WaitForSingleObject are imported correctly. The application freezes when it trys to update the form at Me.Refresh() . Anyway the code is below, any help would be greatly appreciated. Thank you.
EDIT: (Wow sorry that got so long guys)
<br />
...<br />
cExec = "wceload.exe"<br />
cParams = Chr(34) & cabPath & Chr(34) & " /delete 0"<br />
bResult = CreateProcess_Internal(cExec, cParams)<br />
Application.DoEvents()<br />
Me.Refresh()<br />
...<br />
<br />
<br />
Public Function CreateProcess_Internal(ByVal ExeName As String, ByVal CmdLine As String) As Boolean<br />
<br />
Dim result As Int32<br />
Dim si(128) As Byte<br />
Dim pi As New ProcessInfo<br />
<br />
<br />
result = CreateProcess(ExeName, CmdLine, _ <br />
IntPtr.Zero, IntPtr.Zero, 0, 0, IntPtr.Zero, _<br />
IntPtr.Zero, si, pi)<br />
If result = 0 Then Return False<br />
<br />
result = WaitForSingleObject(pi.hThread, WAITNORM)<br />
<br />
CloseHandle(pi.hThread)<br />
CloseHandle(pi.hProcess)<br />
pi = Nothing<br />
<br />
If result <> 0 Then Return False<br />
Return True<br />
<br />
End Function<br />
Sleep is for the WEAK!
-- modified at 9:14 Wednesday 14th June, 2006
|
|
|
|
|
hellow to all ..
i have 2 project in VB.NET now i wanna copy a form from project 1 to project 2 , and keep it 100% full functions , how can i do this ?
thxx for anyhelp ..
|
|
|
|
|
hi
if you don't use any clases or DLLs its should be doce
by copy the from from project1 from the solution explorer
and paste it into ptoject2 in the solution explorer
Tamimi - Code
|
|
|
|
|
right-click on your project add new existing item
................
|
|
|
|
|
i have image stored in the sql database .how can i display image in windows form in the picture box.please help. taher
|
|
|
|
|
http://www.akadia.com/services/dotnet_load_blob.html
|
|
|
|
|
SORRY may my way to wright in english annoying you , but its my best
I need a code for accessing every bit of image file with extinsion(Bmp)
to know what its spicifated RGB value is
Mido
|
|
|
|
|
Use the Bitmap.GetPixel(x,y) method, this will return the Color structure.
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|