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 6713029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:19:50+00:00 2026-05-26T08:19:50+00:00

I seem to be able to find words pretty easily using regex, but I

  • 0

I seem to be able to find words pretty easily using regex, but I have never had to just use the first word of a line before.

The text file looks like this:

List of devices attached
80A004402340333503 device
0123456789ABCDEF device

what I want it to do is to save 80A004402340333503 as device1 and 0123456789ABCDEF as device2

so far I have this:

    If CheckBox4.Checked = True Then
        file = My.Computer.FileSystem.OpenTextFileWriter("c:\devices.bat", False)
        file.WriteLine("@echo off")
        file.WriteLine("cd " & TextBox2.Text)
        file.WriteLine("adb devices > C:\devices.txt")
        file.Close()
        Shell("C:\devices.bat", AppWinStyle.Hide, True, 500)

        Dim devicelines() As String = IO.File.ReadAllLines("C:\devices.txt")
        Dim device1 As String = devicelines(1).First
        Dim device2 As String = devicelines(1).First
    End If

Obviously this doesnt quite work the way I had hoped, but if you could give me a hand in picking the first word in both the 2nd and 3rd line it would be greatly appreciated.

Thans

  • 1 1 Answer
  • 0 Views
  • 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-26T08:19:51+00:00Added an answer on May 26, 2026 at 8:19 am

    A String is just an array of characters.. so when you ask for String.First, you are asking for the first character. What you need to do is split the string into words and then get the first word.

    Something like:

    Dim words() As String = {}
    words = devicelines(1).split(new char() {" "})
    device1 = words(0)
    words = devicelines(2).split(new char() {" "})
    device1 = words(0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I dont seem to be able to find any evidence of multiple groupby being
Is there a destructor for Java? I don't seem to be able to find
I am using the Nitrogen version of Frama-c on Mac, and can't seem able
I don't seem to be able to use a custom route with pagination. The
I know this is a recurrent question but I cannot seem to be able
using C++Builder 2007, the FindFirstFile and FindNextFile functions doesn't seem to be able to
This must be a very simple question, but I don't seem to be able
I've looked everywhere, but can't seem to find a solution to this problem. I'm
I am sure this must have been answered before but I cannot find a
I can't seem to be able to disable ViewState for controls that I add

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.