---
title: Byte.From – แปลงค่าเป็น byte
url: https://www.thepexcel.com/functions/power-query/number-functions/byte-from/
type: function-explainer
program: Power Query
syntax: "Byte.From(value as any, optional culture as nullable text) as nullable number"
date: 2025-12-12
updated: 2025-12-17
scores:
  popularity: 5
  difficulty: 3
  usefulness: 5
---

# Byte.From – แปลงค่าเป็น byte

> แปลงค่าต่างๆ เป็น byte

## คำอธิบาย

Byte.From แปลงค่าต่างๆ เช่น ตัวเลข (number) ข้อความ (text) และค่า boolean เป็นประเภทข้อมูล byte ค่า byte เป็นตัวเลขที่อยู่ในช่วง 0-255 ใช้สำหรับการเก็บข้อมูลไบนารี การเชื่อมต่อ API ที่ต้องข้อมูลไบต์ และการประมวลผลข้อมูลแบบต่ำระดับ

## Syntax

```excel
Byte.From(value as any, optional culture as nullable text) as nullable number
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| value | Yes | any |  | ค่าที่ต้องการแปลง (number, text, boolean ฯลฯ) |
| culture | No | text | null | สำนัก (culture) สำหรับการแปลงข้อความ เช่น "en-US" หรือ "th-TH" |

## เคสการใช้งาน

### แปลงตัวเลขเป็นไบต์

แปลงตัวเลขจาก 0-255 เป็นประเภท byte สำหรับใช้กับข้อมูลไบนารี

_เหมาะกับ:_ numeric-conversion

### แปลงข้อความเป็นไบต์

แปลงค่าข้อความ (เช่น "123") เป็นประเภท byte

_เหมาะกับ:_ text-conversion

### ประมวลผลข้อมูลไบนารี

ใช้ byte เป็นข้อมูลสำหรับการเชื่อมต่อกับ API ที่ต้องข้อมูลไบต์

_เหมาะกับ:_ binary-processing

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: แปลงตัวเลข 150 เป็น byte

```excel
Byte.From(150)
```

**ผลลัพธ์:** `150`

สูตรนี้แปลงค่า 150 เป็นประเภท byte ผลลัพธ์คือ 150 ซึ่งอยู่ในช่วง 0-255

### 2. ตัวอย่างที่ 2: แปลงข้อความ "200" เป็น byte

```excel
Byte.From("200")
```

**ผลลัพธ์:** `200`

สูตรนี้แปลงข้อความ "200" เป็นค่า byte 200 ฟังก์ชันจะแปลงข้อความตัวเลขให้เป็นประเภท byte

### 3. ตัวอย่างที่ 3: แปลงค่า boolean true เป็น byte

```excel
Byte.From(true)
```

**ผลลัพธ์:** `1`

สูตรนี้แปลงค่า true เป็นไบต์ 1 (false จะแปลงเป็น 0) ใช้เป็นตัวแทนสำหรับค่า boolean ในข้อมูลไบนารี

## หมายเหตุเพิ่มเติม

⚠️ ค่า byte มีข้อจำกัด 0-255 ตัวเลขที่อยู่นอกช่วงนี้จะทำให้เกิดข้อผิดพลาด หากต้องการเก็บตัวเลขที่มากกว่า ให้พิจารณาใช้ Number.From หรือ Int32.From แทน

## คำถามที่พบบ่อย

**Q: สามารถแปลงตัวเลขที่มากกว่า 255 ได้หรือไม่**

ไม่ได้ ค่า byte มีช่วง 0-255 ถ้าตัวเลขมากกว่า 255 ฟังก์ชันจะส่งคืนข้อผิดพลาด (error)

**Q: ความแตกต่างระหว่าง Byte.From กับ Number.From**

Byte.From แปลงเป็นไบต์ (0-255) ส่วน Number.From แปลงเป็นตัวเลข (number) ทั่วไปที่ไม่มีข้อจำกัด ใช้ Byte.From สำหรับข้อมูลไบนารี

**Q: ถ้าตัวเลขเป็นลบจะเป็นยังไง**

ค่า byte ต้องเป็นจำนวนเต็มบวกที่อยู่ในช่วง 0-255 ถ้าปลายด้านลบ ฟังก์ชันจะส่งคืนข้อผิดพลาด

## ฟังก์ชันที่เกี่ยวข้อง

- [Number.From – แปลงค่าเป็นตัวเลข](https://www.thepexcel.com/functions/power-query/number-functions/number-from/)
- [Int32.From – แปลงค่าเป็น 32-bit integer](https://www.thepexcel.com/functions/power-query/number-functions/int32-from/)
- [Int64.From – แปลงค่าเป็น 64-bit integer](https://www.thepexcel.com/functions/power-query/number-functions/int64-from/)
- [Text.From – แปลงค่าเป็นข้อความ](https://www.thepexcel.com/functions/power-query/text-functions/text-from/)

## แหล่งข้อมูลเพิ่มเติม

- [Microsoft Learn: Byte.From](https://learn.microsoft.com/en-us/powerquery-m/byte-from) _(documentation)_
- [Power Query M Function Reference](https://learn.microsoft.com/en-us/powerquery-m/power-query-m-function-reference) _(documentation)_

---

_Source: [https://www.thepexcel.com/functions/power-query/number-functions/byte-from/](https://www.thepexcel.com/functions/power-query/number-functions/byte-from/)_
