|
Generally you would open a file handle to the file, read a line in, then process the line, reading up to the first comma, processing that part, reading up to the next comma, processing that part... until you reach the end of the line. After this, read the next line and repeat... Stop when you reach the end of the file.
|
|
|
|
|
This may help:
Reading comma delimited files[^]I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
reading the files in a data set is interesting but using a dataset how would I transfer the data to a string array possible a two dimensional array.
|
|
|
|
|
Does this give you the idea?
Dim arr(ds.MyTable.Rows.Count-1, 1) As String
Dim count as Integer = 0
For Each dr as DataRow in ds.MyTable
arr(count,0) = dr("ID").ToString
arr(count,1) = dr("Name").ToString
count += 1
Next
' do something with the array I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
You might also look here:
TextFieldParser[^]I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
|
I have a application that has a tab control and I create additional tabs dynamically as desired from a template stored in a class. On each Dynamically created tab I have functional buttons and everything works properly. One of the buttons takes the value of one of the dynamically created textboxes and submits it to a function and then the return data is displayed in another dynamically created textbox on the same tab. While this works fine I can only seem to access the the value(Get\Set) of the Textbox via a cast and not sure if this is the best way to achieve this. Is there a Better way???
This is the question code can be found in code below near bottom.
CType(TabControl1.TabPages(TabControl1.SelectedIndex).Controls("txtMaxAddr"), TextBox).Text = "some new text"
----Code---
Public Class CreateTab
Public Function ReadTab(ByRef tpRead As TabPage, ByVal dgCurrentRow As DataGridViewRow)
.
.dynamicaaly created code is here
.
'btnMax
'
btnMax.Location = New System.Drawing.Point(285, 6)
btnMax.Name = "btnMax"
btnMax.Size = New System.Drawing.Size(109, 23)
btnMax.TabIndex = 15
btnMax.Text = "Match to Maximizer"
btnMax.UseVisualStyleBackColor = True
AddHandler btnMax.Click, AddressOf Form1.btnMax_Click
.
.
.
End function
End Class
Private Sub dgInbox_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgInbox.CellDoubleClick
Dim iIndex As Integer
If TabControl1.TabPages.ContainsKey(dgInbox.CurrentRow.Cells(0).Value.ToString()) = False Then
TabControl1.TabPages.Add(dgInbox.CurrentRow.Cells(0).Value.ToString(), Mid(dgInbox.CurrentRow.Cells(2).Value.ToString(), 1, 25))
Me.tpRead.SuspendLayout()
'Call Create tab in above class
CreateTab.ReadTab(TabControl1.TabPages.Item(TabControl1.TabPages.Count - 1), dgInbox.CurrentRow)
Me.tpRead.ResumeLayout(False) Me.tpRead.PerformLayout()
TabControl1.SelectTab(TabControl1.TabPages.Count - 1) 'set to currently displayed tab
Else
iIndex = TabControl1.TabPages.IndexOfKey(dgInbox.CurrentRow.Cells(0).Value.ToString())
TabControl1.SelectTab(iIndex) ' tab already was created display it
End If
End Sub
-------------
Public Sub btnMax_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMax.Click
Dim EmailAddr As String
Dim AccountInfo As String
EmailAddr = TabControl1.TabPages(TabControl1.SelectedIndex).Controls("txtRdFrom").Text
MaxConn.LinkToAccount(EmailAddr, AccountInfo)
'---Code Question Below--- :confused:
CType(TabControl1.TabPages(TabControl1.SelectedIndex).Controls("txtMaxAddr"), TextBox).Text = AccountInfo
End Sub Thanks in advance...
dotnetme2
|
|
|
|
|
I expect it works well without the cast, since Controls[] returns a Control, and every Control has a Text property. What happens when you try without CType(..., TextBox)? Does it compile? What error or exception are you getting?
|
|
|
|
|
I must have been typeing something wrong, because I swore the other day I was getting an error readonly or property error... But as you stated it worked fine... Because I get the value the way you suggest as well, I don't know why it didn't prior...
Sorry to waste your time...
this leads me to my next question which is a bit more complicated and up your ally... but still reading...
thanks...dotnetme2
|
|
|
|
|
No problem.
|
|
|
|
|
I am using MS Graph Chart (MSGraph.Chart8) in an Access2007 form to represent a work schedule.
My vertical axis contains the days of the schedule (Day 1, Day 2,...) and along the horizontal are the hours of the day (00 to 24) - 24 hr segments.
If a shift starts in Day 1 at 10pm (22:00) and goes for 8 hours, it will extend into Day 2.
My question: do you know how to change the color of individual data series (bar)?
For hours that roll-over into the next day, I want to distinguish with a different color than the rest of the bars (data series) which are all same color.
Bigger question: i want to control more properties of the MS Graph Chart object so I can resize/scale my vertical axis to accomodate several labels (Days).
Thank you.
John
|
|
|
|
|
I have a problem . I have to draw a circle at a particular distance say 50 meters from a given lat/log.I refered to Aviation formula's and find a formula to calculate lat/log at a distance and
at a bearing which is as follows:-
A point {lat,lon} is a distance d out on the tc radial from point 1 if:
lat=asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos
(tc))
IF (cos(lat)=0)
lon=lon1 // endpoint a pole
ELSE
lon=mod(lon1-asin(sin(tc)*sin(d)/cos
(lat))+pi,2*pi)-pi
ENDIF
This algorithm is limited to distances such that dlon <pi/2, i.e those that extend around less
than one quarter of the circumference of the earth in longitude. A completely general, but more complicated algorithm is necessary if greater distances are allowed:
lat =asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc))
dlon=atan2(sin(tc)*sin(d)*cos(lat1),cos(d)-sin
(lat1)*sin(lat))
lon=mod( lon1-dlon +pi,2*pi )-pi
for this i have written this coding:-
Private Sub cmdNextPoint_Click()
Dim lat2 As Double, lon2 As Double, theta As Double, d As Double,Aasin As Double,Aatan2 As Double
Pi = 3.14159265358979
d = 50
theta = 90 * 0.0174532925
txtLatitude.Text = 22.51791
txtLongitude.Text = 87.46598
Aasin = Sin(Val(txtLatitude.Text)) * Cos(d) + Cos(Val(txtLatitude.Text)) * Sin(d) * Cos(theta)
lat2 = atan2(Aasin, Sqr(1 - Aasin * Aasin))
Aatan2 = Sin(theta) * Sin(d) * Cos(Val(txtLatitude.Text))
Batan2 = Cos(d) - Sin(Val(txtLatitude.Text)) * Sin(lat2)
lon2 = ((Val(txtLongitude.Text) - atan2(Aatan2, Batan2) + Pi) Mod (2 * Pi)) - Pi
txtLatitude2.Text = lat2
txtLongitude2.Text = lon2
End Sub
Public Function atan2(ByVal y As Double, ByVal x As Double) As Double
If y > 0 Then
If x >= y Then
atan2 = Atn(y / x)
ElseIf x <= -y Then
atan2 = Atn(y / x) + Pi
Else
atan2 = Pi / 2 - Atn(x / y)
End If
Else
If x >= -y Then
atan2 = Atn(y / x)
ElseIf x <= y Then
atan2 = Atn(y / x) - Pi
Else
atan2 = -Atn(x / y) - Pi / 2
End If
End If
End Function
in this i m finding a point which is at a distance of 50 meters from the latitude 22.51791 and longitude 87.46598 and at a bearing of 90 degrees.Somebody told me that to draw a circle i have to find out 360 points then by using the DrawPolygon method the circle can be drawn.So firstly i m finding one point.It is not giving me the desired result that should be latitude = 22.51841 and longitude = 87.46598.Can anybody help me .Just tell me where i m wrong.I m using the mapwingis activex control to display the map.
|
|
|
|
|
Hi,
I did not look into your code or formulas as they are pretty unreadable; you should enclose the lot with PRE tags.
If you get trig functions completely wrong, the most likely cause is you forgot in most languages and math packages the angular units are radians, not degrees. So you need a factor, say in C#:
double ToRadians=Math.PI/180;
or something similar in VB.NET
PS: Notice the effect of PRE tags?
|
|
|
|
|
I'm no expert on the math, but it appears that not all the values you are passing to the Trig functions are expressed in Radians. It appears that you're using Radians in some calls, but Degrees in others. This will definately give you bad results.
|
|
|
|
|
Visual
I have design a form(frmembmst). On the particular form i have used a text box. On the lost focus of text box i have called a form(frmhelp) which have many contorl (textbox,datagrid view,two command buttons(ok,cancel)).
On the event of text change (frmhelp) record are coming succesfully.
My question is :
when I type any text in text Box focus should go on partiular cell.
if i click and enter on ok-command button then selected record should set in frmembmst-textbox.
Thanks
From
Ganesh Joshimodified on Thursday, March 18, 2010 3:24 AM
|
|
|
|
|
in which language are you working ?. Their are number of grids available which provide more then that functionality. what problem are you facing? SOFTDEV
If you have knowledge, let others light their candles at it. [ Let's work to help developers, not make them feel stupid ]
|
|
|
|
|
what are the basic things we need to do automation in vb? with back end as ms access.
|
|
|
|
|
What do you need to automate? The code for automatng a robot would be vastly different from the code to automate excel or word. Please be more specific.
|
|
|
|
|
You need to do two things:
1. Read the sticky posts above.
2. Define automation.
|
|
|
|
|
can v use vb in excel? if s how to use?
|
|
|
|
|
Again, would you mind being a bit descriptive. Are you looking to play with Excel from a VB code or want to do something like macro.
|
|
|
|
|
ya some thing like macro.
|
|
|
|
|
it is something like i should have list box with list of employee names and a button start and stop. while clicking start button the employee time of work starts after his work gets over he wil press stop button. this is my requirement.
|
|
|
|
|
Yes we can use vb in EXCEL that is called VBA. If you can think then I Can.
|
|
|
|
|
You can use VBA in Excel, use the Developer section and it is there.
Within this you can call a VB program from within the VBA.
It is very flexible.------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|