Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 251513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:36:02+00:00 2026-05-11T21:36:02+00:00

i have a text file with the following data: Calculated Concentrations 30.55 73.48 298.25

  • 0

i have a text file with the following data:

Calculated Concentrations
30.55 73.48 298.25 27.39 40.98 11.21 99.22 33.46 73.99 12.18 30.7
50 28.4 34.33 29.55 70.48 43.09 28.54 50.78 9.68 62.03 63.18 28.4
100 23.83 68.65 10.93 ?????? 31.42 8.16 24.97 8.3 114.97 34.92 15.53
200 32.15 29.98 23.69 ?????? 23.41 33.6 92.03 32.73 13.58 58.44 94.61
400 159.98 18.05 50.94 37.12 15.25 46.75 315.22 69.98 13.58 ?????? 58.77
208.82 11.07 38.15 86.31 35.5 41.88 28.25 5.39 40.83 29.98 54.42 69.48
36.09 13.16 23.26 19.31 147.56 31.86 6.77 19.45 33.6 32.87 205.47 134.21
?????? 17.35 9.96 58.61 13.44 23.97 22.13 145.17 29.55 26.54 37.12 198.33

and i would like to load this data into an array.

  1. how do i enable the user to open a file of his choosing in vb.net?
  2. how do i read these values into an array in vb.net?

i would like to clarify that what person-b has suggested works very very well. specifically the fields = calculationText.split(” “) was exactly what i needed; however, my next issue is the following. the data above is actually in this format:

http://pastebin.com/d29ae565b

where the i need the first value to be 0, then 50, then 100 etc. and i need it to read columns from left to right. the problem is that the values are not reading into the array in this manner. the values are actually reading like this: 6.65, 84.22, ????, 35.15. please help!

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T21:36:02+00:00Added an answer on May 11, 2026 at 9:36 pm

    To read a file into a String variable, in VB.NET, you can use the System.IO.File.ReadAllText() function. An example is:

    Imports System.IO '// placed at the top of the file'
    
    '// some code'
    
    Dim calculationText As String
    calculationText = File.ReadAllText("calculations.txt") '// gets all the text in the file'
    

    Where "calculations.txt" is the file name.

    To your next point – to allow the user to load a file of their choosing, you can use the OpenFileDialog type. An example:

    Dim fileName As String
    Dim openDlg As OpenFileDialog
    openDlg = New OpenFileDialog() '// make a new dialog'
    If openDlg.ShowDialog() = DialogResult.OK Then
        '// the user clicked OK'
        fileName = openDlg.FileName '// openDlg.FileName is where it keeps the selected name'
    End If
    

    Combining this, we get:

    Imports System.IO 
    
    '// other code in the file'
    
    Dim fileName As String
    Dim openDlg As OpenFileDialog
    openDlg = New OpenFileDialog() '// make a new dialog'
    If openDlg.ShowDialog() = DialogResult.OK Then
        '// the user clicked OK'
        fileName = openDlg.FileName
    End If
    
    Dim calculationText As String
    calculationText = File.ReadAllText(fileName)
    

    Now, we need to process the input. First, we need to make a list of decimal numbers. Next, we put everything in the file that is a number in the list:

    Dim numbers As List(Of Decimal)
    numbers = New List(Of Decimal)() '// make a new list'
    
    Dim fields() As String
    fields = calculationText.Split(" ") '// split all the text by a space.'
    
    For Each field As String in fields '// whats inside here gets run for every thing in fields'
        Dim thisNumber As Decimal
        If Decimal.TryParse(field, thisNumber) Then '// if it is a number'
            numbers.Add(thisNumber) '// then put it into the list'  
        End If
    Next
    

    This won’t include Calculated Concentrations or ????? in the list. For usable code, just combine the second and last code samples.

    EDIT: In response to the comment below.
    With List objects, you can index them like this:

    Dim myNumber As Decimal
    myNumber = numbers(1)
    

    You do not need to use the Item property. Also, when showing it in a message box, you need to turn it into a String type first, like this:

    MsgBox(myNumber.ToString())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tab delimited text file with the following data: ahi1 b/se ahi
I have a text file containing the data in following format 12345 Abdt3 hy45d
I have a text file with the following type of data in it below:
I have the following data in a text file. 10993 39750 11002 10993 39751
I have a text file in the following url. http://hosted.stats.com/ifb2009/data.asp?file=en/chlg_standings.txt I want to parse
I have a large text file ( data ) which has the following layout:
Lets say I have a text file with the following data Username User ID
Suppose I have a plain text file with the following data: DataSetOne <br />
I have the following data (from a text file), I would like to split
I have the following like data in a tab-delimted text file named original Name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.